Network total reforge. Team-List and Race-Data handled

This commit is contained in:
2025-06-29 19:04:36 +02:00
parent 3a45d4c3b7
commit 81bf37639b
92 changed files with 3736 additions and 4202 deletions

View File

@ -0,0 +1,95 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Assets/DTFluxModelAsset.h"
#include "DTFluxCoreModule.h"
#include "Types/Objects/DTFluxContestStorage.h"
// const FDateTime UDTFluxModelAsset::GetMassStart(const int& ContestId, const int& StageId)
// {
// }
// void UDTFluxModelAsset::InsertOrUpdateRaceData(const TSharedPtr<FJsonObject>& Response)
// {
//
// }
//
// void UDTFluxModelAsset::InsertOrUpdateContestRanking(const TSharedPtr<FJsonObject>& Response)
// {
// }
//
// void UDTFluxModelAsset::InsertOrUpdateStageRanking(const TSharedPtr<FJsonObject>& Response)
// {
// }
//
// void UDTFluxModelAsset::InsertOrUpdateSplitRanking(const TSharedPtr<FJsonObject>& Response)
// {
// }
//
// void UDTFluxModelAsset::InsertOrUpdateTeamList(const TSharedPtr<FJsonObject>& Response)
// {
// }
//
// void UDTFluxModelAsset::SplitSensorTriggered(const TSharedPtr<FJsonObject>& Response)
// {
// }
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;
});
}

View File

@ -0,0 +1,19 @@
#include "DTFluxCoreModule.h"
#define LOCTEXT_NAMESPACE "FDTFluxCoreModule"
DTFLUXCORE_API DEFINE_LOG_CATEGORY(logDTFluxCore);
void FDTFluxCoreModule::StartupModule()
{
}
void FDTFluxCoreModule::ShutdownModule()
{
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FDTFluxCoreModule, DTFluxCore)

View File

@ -0,0 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Types/Objects/DTFluxContestSchedule.h"

View File

@ -0,0 +1,139 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Types/Objects/DTFluxContestStorage.h"
void UDTFluxContestStorage::Initialize()
{
}
// bool UDTFluxContestStorage::InitializeRaceData(const FDTFluxRaceDataDefinition& InRaceDataResponse)
// {
// return false;
// }
//
// bool UDTFluxContestStorage::InitializeTeamList(const FDTFluxTeamListDefinition& InTeamListDefinition)
// {
// return false;
// }
//
// bool UDTFluxContestStorage::UpdateParticipantStatus(const FDTFluxTeamListDefinition& InTeamListDefinition)
// {
// return false;
// }
#pragma region ContestRegion
const FDTFluxContest& UDTFluxContestStorage::GetCurrentContest() const
{
return CurrentContest;
}
const FDTFluxStage& UDTFluxContestStorage::GetCurrentStage(const int InContest, const int InStage)
{
return CurrentStage;
}
void UDTFluxContestStorage::AddContest(const FDTFluxContest InContest)
{
}
//
// void UDTFluxContestStorage::AddContestResponse(const FDTFluxContestResponse& InContestResponse)
// {
// }
#pragma endregion
#pragma region ContestRankingRegion
void UDTFluxContestStorage::GetContestRankings(const TArray<FDTFluxContestRanking> OutContestRanking, const int InContestId, const bool bShouldSortByRank,
const bool bShouldSkipEmpty)
{
}
void UDTFluxContestStorage::GetContestRankingsSorted(const TArray<FDTFluxContestRanking> OutSortedContestRankings, const int InContestId, const EDTFluxSortingFilter InFilter,
const bool bShouldSkipEmpty)
{
}
#pragma endregion
#pragma region StageRegion
void UDTFluxContestStorage::GetStage(const int InContest, const int InStage, const FDTFluxStage& OutStage)
{
}
void UDTFluxContestStorage::GetStages(const int InContest, TArray<FDTFluxStage> OutStages)
{
}
void UDTFluxContestStorage::GetStageCurrentStage(const FDTFluxStage& OutStage)
{
}
void UDTFluxContestStorage::AddStage(const int InContest, const FDTFluxStage& InStage)
{
}
// void UDTFluxContestStorage::AddStageResponse(const int InContestId, const FDTFluxStageResponse& StageResponse)
// {
// }
#pragma endregion
#pragma region StageRankingRegion
void UDTFluxContestStorage::AddStageRanking(const int InContest, const FDTFluxStageRanking& InStageRanking)
{
}
#pragma endregion
#pragma region SplitRegion
void UDTFluxContestStorage::AddSplit(const int InContest, const FDTFluxSplit& InSplit)
{
}
#pragma endregion
#pragma region SplitRankingRegion
void UDTFluxContestStorage::AddSplitRanking(const int InContest, const FDTFluxSplitRanking& InSplitRanking)
{
}
void UDTFluxContestStorage::GetSplitRankingByParticipant(const FDTFluxParticipant& InParticipant, const int InContestId,
const int InStageId, const FDTFluxSplitRanking& OutSplitRankingForBib)
{
}
void UDTFluxContestStorage::GetSplitRankingByBib(const int InBib, const int InContestId, const int InStageId,
const FDTFluxSplitRanking& OutSplitRankingForBib)
{
}
#pragma endregion
#pragma region ParticipantSection
void UDTFluxContestStorage::GetParticipantsForContest(const int InContestId,
const TArray<FDTFluxParticipant> OutParticipants)
{
}
void UDTFluxContestStorage::GetPoursuiteStartupLine(const int InContestId,
const TArray<FDTFluxParticipant> OutParticipants)
{
}
FDateTime UDTFluxContestStorage::GetMassStart(const int InContestId)
{
return FDateTime();
}
#pragma endregion
void UDTFluxContestStorage::SetCurrentContest()
{
}

View File

@ -0,0 +1,3 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Types/Struct/DTFluxRaceDataStructs.h"

View File

@ -0,0 +1,29 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Types/Struct/DTFluxRankingStructs.h"
#include "DTFluxCoreModule.h"
void FDTFluxContestRanking::Dump() const
{
UE_LOG(logDTFluxCore, Log,
TEXT("FDTFluxContestRanking ->> \n \"rank\" : %d, Participant with Bib %d \"Gap\" : %s, \"Time\" : %s "),
Rank, Bib, *Gap, *Time );
};
void FDTFluxStageRanking::Dump() const
{
UE_LOG(logDTFluxCore, Log, TEXT("RANKING : %02d. Participant bib %d %s %s %s %s %s"),
Rank, Bib, *Gap, *TimeSwim,
*TimeTransition, *TimeRun, *StartTime.ToString());
}
void FDTFluxSplitRanking::Dump() const
{
UE_LOG(logDTFluxCore, Log, TEXT("SplitGapItem"))
// Participant.Dump();
UE_LOG(logDTFluxCore, Log, TEXT("Bib %02d Rank %02d Gap %s Time %s"), Bib, Rank, *Gap, *Time);
}

View File

@ -0,0 +1,107 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Types/Struct/DTFluxTeamListStruct.h"
bool FDTFluxParticipant::IsTeam() const
{
return Person2.FirstName.IsEmpty() && Person2.LastName.IsEmpty();
}
void FDTFluxParticipant::Dump() const
{
FString EliteStr = "NO";
if(Elite)
{
EliteStr = "YES";
}
UE_LOG(logDTFluxCore, Log, TEXT("PARTICIPANT with bib: %03d"), Bib);
UE_LOG(logDTFluxCore, Log, TEXT("Fullname : %s %s"), *Person1.FirstName, *Person1.LastName);
if(IsTeam())
{
UE_LOG(logDTFluxCore, Log, TEXT("Teamate : %s %s"), *Person2.FirstName, *Person2.LastName);
UE_LOG(logDTFluxCore, Log, TEXT("Team name : %s"), *Team);
}
UE_LOG(logDTFluxCore, Log, TEXT("Club : %s, Category : %s, IsElite : %s, Status : %s"),
*Club, *Category, *EliteStr, *UEnum::GetValueAsString(Status));
}
FString FDTFluxParticipant::GetParticipantFormatedName(bool Truncate, int MaxSize) const
{
FString ParticipantName;
if(Truncate)
{
if(IsTeam())
{
//Concatenate the team name;
if(Team.Len() > MaxSize - 3)
{
return Team.Left(MaxSize - 3).Append(TEXT("..."));
}
return Team;
}
if(Person1.FirstName.Contains("-") )
{
FString Formated = "";
//Compound Firstname
TArray<FString> Out;
Person1.FirstName.ParseIntoArray(Out,TEXT("-"),true);
for(const auto& Str : Out)
{
Formated.Append(Str.Left(1).ToUpper()).Append(".");
}
// TODO : Camel Case handling for LastName
Formated.Append(" ").Append(*Person1.LastName);
UE_LOG(logDTFluxCore, Log, TEXT("Firstname is with space compound. Formated Name %s length %02d MAX Size : %02d"),
*Formated, Formated.Len(), MaxSize);
if(Formated.Len() >= MaxSize)
{
UE_LOG(logDTFluxCore, Log, TEXT("Reducing %s Formated"), *Formated);
return Formated.Left(MaxSize - 3).Append("...");
}
return Formated;
}
if(Person1.FirstName.Contains(" "))
{
FString Formated = "";
//Compound Firstname
TArray<FString> Out;
Person1.FirstName.ParseIntoArray(Out,TEXT(" "),true);
for(const auto& Str : Out)
{
Formated.Append(Str.Left(1).ToUpper()).Append(".");
}
// TODO : Camel Case handling for LastName
Formated.Append(" ").Append(*Person1.LastName);
UE_LOG(logDTFluxCore, Log, TEXT("Firstname is with space compound. Formated Name %s length %02d MAX Size : %02d"),
*Formated, Formated.Len(), MaxSize);
if(Formated.Len() >= MaxSize)
{
UE_LOG(logDTFluxCore, Log, TEXT("Reducing %s Formated"), *Formated);
return Formated.Left(MaxSize - 3).Append("...");
}
return Formated;
}
FString Formated = Person1.FirstName.Left(1).Append(". ");
Formated.Append(Person1.LastName);
UE_LOG(logDTFluxCore, Log, TEXT("Firstname is not compound. Formated Name %s length %02d MAX Size : %02d"),
*Formated, Formated.Len(), MaxSize);
if(Formated.Len() >= MaxSize)
{
UE_LOG(logDTFluxCore, Log, TEXT("Reducing %s Formated"), *Formated);
return Formated.Left(MaxSize - 3).Append("...");
}
return Formated;
}
else
{
if(!IsTeam())
{
return FString::Printf(TEXT("%s %s"), *Person1.FirstName, *Person2.LastName);
}
return Team;
}
}

View File

@ -0,0 +1,9 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Types/Struct/FDTFluxPoursuiteStruct.h"
FText FDTFluxPoursuite::GetParticipantFormatedName() const
{
return FText();
}