2025-06-29 19:04:36 +02:00
|
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Assets/DTFluxModelAsset.h"
|
|
|
|
|
|
#include "DTFluxCoreModule.h"
|
|
|
|
|
|
#include "Types/Objects/DTFluxContestStorage.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UDTFluxModelAsset::UDTFluxModelAsset(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UDTFluxModelAsset::AddContest(const FDTFluxContest &Contest)
|
|
|
|
|
|
{
|
|
|
|
|
|
Contests.Add(Contest.Name, Contest);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UDTFluxModelAsset::GetContestById(const int InContestId, FDTFluxContest& OutContest)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(auto& ContestItem : Contests)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(ContestItem.Value.ContestId == InContestId)
|
|
|
|
|
|
{
|
|
|
|
|
|
OutContest = ContestItem.Value;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UDTFluxModelAsset::AddPerson(const FDTFluxPerson& InPerson)
|
|
|
|
|
|
{
|
|
|
|
|
|
Persons.Add(InPerson);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UDTFluxModelAsset::AddParticipant(const FDTFluxParticipant& InParticipant, const int ContestId)
|
|
|
|
|
|
{
|
|
|
|
|
|
FDTFluxContest TargetContest;
|
|
|
|
|
|
if(GetContestById(ContestId, TargetContest))
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!PersonExists(InParticipant.Person1))
|
|
|
|
|
|
{
|
|
|
|
|
|
AddPerson(InParticipant.Person1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(InParticipant.Person2 != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(!PersonExists(InParticipant.Person2))
|
|
|
|
|
|
{
|
|
|
|
|
|
AddPerson(InParticipant.Person2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Participants.Add(InParticipant.Bib, InParticipant);
|
|
|
|
|
|
TargetContest.ParticipantsBib.Add(InParticipant.Bib);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UDTFluxModelAsset::PersonExists(const FDTFluxPerson& InPerson) const
|
|
|
|
|
|
{
|
|
|
|
|
|
return Persons.ContainsByPredicate([InPerson](const FDTFluxPerson& Person)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Person == InPerson;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-06-30 19:02:19 +02:00
|
|
|
|
|
|
|
|
|
|
FString UDTFluxModelAsset::GetContestNameForId(const int InContestID)
|
|
|
|
|
|
{
|
|
|
|
|
|
FDTFluxContest Contest;
|
|
|
|
|
|
if(!GetContestById(InContestID, Contest))
|
|
|
|
|
|
{
|
|
|
|
|
|
UE_LOG(logDTFluxCore, Warning, TEXT("GetContestNameForId(%i) [unable to find a contest] result will be empty !!!"),
|
|
|
|
|
|
InContestID);
|
|
|
|
|
|
}
|
|
|
|
|
|
return Contest.Name;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void UDTFluxModelAsset::AddContestRanking(const FDTFluxContestRankings& NewContestRankings)
|
|
|
|
|
|
{
|
|
|
|
|
|
ContestRankings.Add(NewContestRankings.ContestId, NewContestRankings);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UDTFluxModelAsset::UpdateStageRanking(const FDTFluxStageRankings& InStageRankings)
|
|
|
|
|
|
{
|
|
|
|
|
|
const int ContestId = InStageRankings.ContestId;
|
|
|
|
|
|
const int StageId = InStageRankings.StageId;
|
|
|
|
|
|
int Index = 0;
|
|
|
|
|
|
int StageRankingArraySize = StageRankings.Num()-1;
|
|
|
|
|
|
for(auto Ranking : StageRankings)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(Ranking.ContestId == ContestId && Ranking.StageId == StageId)
|
|
|
|
|
|
{
|
|
|
|
|
|
Index++;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
Index++;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(Index != StageRankingArraySize )
|
|
|
|
|
|
{
|
|
|
|
|
|
StageRankings[Index] = InStageRankings;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UDTFluxModelAsset::UpdateSplitRanking(const FDTFluxStageRankings& InStageRankings)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|