Core Structure cleaning
This commit is contained in:
@ -1,3 +1,67 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
#include "Types/Struct/DTFluxRaceDataStructs.h"
|
#include "Types/Struct/DTFluxRaceDataStructs.h"
|
||||||
|
|
||||||
|
bool FDTFluxContest::IsFinished() const
|
||||||
|
{
|
||||||
|
return EndTime <= FDateTime::Now();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FDTFluxContest::UpdateEndTime()
|
||||||
|
{
|
||||||
|
TArray<FDTFluxStage> TempStages = Stages;
|
||||||
|
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||||
|
{
|
||||||
|
return A.EndTime < B.EndTime;
|
||||||
|
});
|
||||||
|
EndTime = TempStages.Last().EndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FDTFluxContest::GetLastStageId()
|
||||||
|
{
|
||||||
|
if (LastStageId <= 0)
|
||||||
|
{
|
||||||
|
UpdateLastStageId();
|
||||||
|
}
|
||||||
|
return LastStageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FDTFluxContest::UpdateLastStageId()
|
||||||
|
{
|
||||||
|
TArray<FDTFluxStage> TempStages = Stages;
|
||||||
|
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||||
|
{
|
||||||
|
return A.StageId < B.StageId;
|
||||||
|
});
|
||||||
|
LastStageId = TempStages.Last().StageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
FDTFluxStage& FDTFluxContest::GetLastStage() const
|
||||||
|
{
|
||||||
|
TArray<FDTFluxStage> TempStages = Stages;
|
||||||
|
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||||
|
{
|
||||||
|
return A.StageId < B.StageId;
|
||||||
|
});
|
||||||
|
return TempStages.Last();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FDTFluxContest::GetStage(const int StageID, FDTFluxStage& OutStage) const
|
||||||
|
{
|
||||||
|
if (Stages.Num() == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (const FDTFluxStage& Stage : Stages)
|
||||||
|
{
|
||||||
|
if (Stage.StageId == StageID)
|
||||||
|
{
|
||||||
|
OutStage = Stage;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,40 +1,197 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
#include "Types/Struct/DTFluxTeamListStruct.h"
|
#include "Types/Struct/DTFluxTeamListStruct.h"
|
||||||
|
|
||||||
#include "DTFluxCoreModule.h"
|
#include "DTFluxCoreModule.h"
|
||||||
|
#include "Dom/JsonObject.h"
|
||||||
|
|
||||||
|
// ===================================
|
||||||
|
// FDTFluxPerson Implementation
|
||||||
|
// ===================================
|
||||||
|
|
||||||
|
bool FDTFluxPerson::operator==(const FDTFluxPerson& Right) const
|
||||||
|
{
|
||||||
|
return GetNormalizedString() == Right.GetNormalizedString();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FDTFluxPerson::operator!=(const FDTFluxPerson& Right) const
|
||||||
|
{
|
||||||
|
return !(*this == Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FDTFluxPerson::operator==(const int Length) const
|
||||||
|
{
|
||||||
|
return GetNormalizedString().Len() == Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FDTFluxPerson::operator!=(const int Length) const
|
||||||
|
{
|
||||||
|
return !(*this == Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
FString FDTFluxPerson::GetNormalizedString() const
|
||||||
|
{
|
||||||
|
return FirstName.ToLower() + LastName.ToLower() + Gender.ToLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FDTFluxPerson::IsValid() const
|
||||||
|
{
|
||||||
|
return !FirstName.TrimStartAndEnd().IsEmpty() &&
|
||||||
|
!LastName.TrimStartAndEnd().IsEmpty() &&
|
||||||
|
!Gender.TrimStartAndEnd().IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
FDTFluxParticipant::FDTFluxParticipant()
|
||||||
|
: Bib(-1)
|
||||||
|
, ContestId(-1)
|
||||||
|
, Elite(false)
|
||||||
|
, Status(static_cast<EDTFluxParticipantStatusType>(0))
|
||||||
|
, bIsMassStartParticipant(false)
|
||||||
|
, CurrentSplit(-1)
|
||||||
|
{
|
||||||
|
Teammate.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
FDTFluxParticipant::FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject)
|
||||||
|
: Bib(JsonObject->GetIntegerField(TEXT("bib")))
|
||||||
|
, ContestId(JsonObject->GetIntegerField(TEXT("contestId")))
|
||||||
|
, Category(JsonObject->GetStringField(TEXT("category")))
|
||||||
|
, Club(JsonObject->GetStringField(TEXT("club")))
|
||||||
|
, Elite(JsonObject->GetBoolField(TEXT("elite")))
|
||||||
|
, Status(static_cast<EDTFluxParticipantStatusType>(JsonObject->GetIntegerField(TEXT("status"))))
|
||||||
|
, Team(JsonObject->GetStringField(TEXT("team")))
|
||||||
|
, CurrentSplit(-1)
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxCore, Log, TEXT("Creating participant from JSON - Bib: %d, Contest: %d"), Bib, ContestId);
|
||||||
|
|
||||||
|
for (uint8 Index = 1; Index <= 10; Index++)
|
||||||
|
{
|
||||||
|
FString FirstNameKey = Index == 1 ? TEXT("firstName") : FString::Printf(TEXT("firstName%d"), Index);
|
||||||
|
FString LastNameKey = Index == 1 ? TEXT("lastName") : FString::Printf(TEXT("lastName%d"), Index);
|
||||||
|
FString GenderKey = Index == 1 ? TEXT("gender") : FString::Printf(TEXT("gender%d"), Index);
|
||||||
|
|
||||||
|
// Vérifie si au moins un des champs existe
|
||||||
|
if (!JsonObject->HasField(FirstNameKey) && !JsonObject->HasField(LastNameKey) && !JsonObject->HasField(GenderKey))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FString FirstName = JsonObject->GetStringField(FirstNameKey);
|
||||||
|
const FString LastName = JsonObject->GetStringField(LastNameKey);
|
||||||
|
const FString Gender = JsonObject->GetStringField(GenderKey);
|
||||||
|
|
||||||
|
if (FirstName.TrimStartAndEnd().IsEmpty() && LastName.TrimStartAndEnd().IsEmpty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FDTFluxPerson Person;
|
||||||
|
Person.FirstName = FirstName.TrimStartAndEnd();
|
||||||
|
Person.LastName = LastName.TrimStartAndEnd();
|
||||||
|
Person.Gender = Gender.TrimStartAndEnd();
|
||||||
|
|
||||||
|
if (Person.IsValid())
|
||||||
|
{
|
||||||
|
Teammate.Add(Person);
|
||||||
|
UE_LOG(logDTFluxCore, Verbose, TEXT("Added person %d: %s %s (%s)"),
|
||||||
|
Index, *Person.FirstName, *Person.LastName, *Person.Gender);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxCore, Warning, TEXT("Invalid person data at index %d: '%s' '%s' '%s'"),
|
||||||
|
Index, *FirstName, *LastName, *Gender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UE_LOG(logDTFluxCore, Log, TEXT("Participant created with %d teammates"), Teammate.Num());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FDTFluxParticipant::IsDefault() const
|
||||||
|
{
|
||||||
|
return Bib == -1
|
||||||
|
&& ContestId == -1
|
||||||
|
&& Category.IsEmpty()
|
||||||
|
&& Club.IsEmpty()
|
||||||
|
&& !Elite
|
||||||
|
&& Status == static_cast<EDTFluxParticipantStatusType>(0)
|
||||||
|
&& Team.IsEmpty()
|
||||||
|
&& !bIsMassStartParticipant
|
||||||
|
&& CurrentSplit == -1
|
||||||
|
&& Teammate.IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void FDTFluxParticipant::AddTeammate(const FDTFluxPerson& Person)
|
void FDTFluxParticipant::AddTeammate(const FDTFluxPerson& Person)
|
||||||
|
{
|
||||||
|
if (Person.IsValid())
|
||||||
{
|
{
|
||||||
Teammate.Add(Person);
|
Teammate.Add(Person);
|
||||||
|
UE_LOG(logDTFluxCore, Verbose, TEXT("Added teammate: %s %s"), *Person.FirstName, *Person.LastName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxCore, Warning, TEXT("Cannot add invalid teammate: %s %s"), *Person.FirstName, *Person.LastName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FDTFluxParticipant::AddTeammate(const FString LastName, const FString FirstName, const FString Gender)
|
void FDTFluxParticipant::AddTeammate(const FString& LastName, const FString& FirstName, const FString& Gender)
|
||||||
{
|
{
|
||||||
|
FDTFluxPerson Person;
|
||||||
|
Person.FirstName = FirstName.TrimStartAndEnd();
|
||||||
|
Person.LastName = LastName.TrimStartAndEnd();
|
||||||
|
Person.Gender = Gender.TrimStartAndEnd();
|
||||||
|
|
||||||
|
AddTeammate(Person);
|
||||||
}
|
}
|
||||||
|
|
||||||
FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString Separator,
|
int FDTFluxParticipant::GetTeammateNum() const
|
||||||
const FString OverflowChars) const
|
|
||||||
{
|
{
|
||||||
|
return Teammate.Num();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FDTFluxParticipant::IsTeam() const
|
||||||
|
{
|
||||||
|
return Teammate.Num() > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TArray<FDTFluxPerson>& FDTFluxParticipant::GetTeammate() const
|
||||||
|
{
|
||||||
|
return Teammate;
|
||||||
|
}
|
||||||
|
|
||||||
|
FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString& Separator, const FString& OverflowChar) const
|
||||||
{
|
{
|
||||||
if (MaxChar <= 0)
|
if (MaxChar <= 0)
|
||||||
{
|
{
|
||||||
return "";
|
return TEXT("");
|
||||||
}
|
}
|
||||||
|
|
||||||
FString FirstName;
|
FString FirstName;
|
||||||
FString LastName;
|
FString LastName;
|
||||||
|
|
||||||
if (IsTeam())
|
if (IsTeam())
|
||||||
|
{
|
||||||
|
if (!Team.IsEmpty())
|
||||||
{
|
{
|
||||||
LastName = Team;
|
LastName = Team;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
TArray<FString> Names;
|
||||||
|
for (const FDTFluxPerson& Person : Teammate)
|
||||||
|
{
|
||||||
|
Names.Add(Person.LastName);
|
||||||
|
}
|
||||||
|
LastName = FString::Join(Names, TEXT("/"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Teammate.Num() > 0)
|
||||||
{
|
{
|
||||||
FirstName = Teammate[0].FirstName;
|
FirstName = Teammate[0].FirstName;
|
||||||
LastName = Teammate[0].LastName;
|
LastName = Teammate[0].LastName;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LastName = TEXT("Unknown");
|
||||||
|
}
|
||||||
FString Initial;
|
FString Initial;
|
||||||
if (!FirstName.IsEmpty())
|
if (!FirstName.IsEmpty())
|
||||||
{
|
{
|
||||||
@ -42,16 +199,14 @@ FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
FString FormattedLastName = LastName.ToUpper();
|
FString FormattedLastName = LastName.ToUpper();
|
||||||
|
|
||||||
FString FullName = Initial + FormattedLastName;
|
FString FullName = Initial + FormattedLastName;
|
||||||
UE_LOG(logDTFluxCore, VeryVerbose, TEXT("FullName for Bib %i is %s"), Bib, *FullName);
|
|
||||||
|
|
||||||
if (FullName.Len() <= MaxChar)
|
if (FullName.Len() <= MaxChar)
|
||||||
{
|
{
|
||||||
return FullName;
|
return FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int32 OverflowLength = OverflowChars.Len();
|
const int32 OverflowLength = OverflowChar.Len();
|
||||||
|
|
||||||
if (OverflowLength > MaxChar)
|
if (OverflowLength > MaxChar)
|
||||||
{
|
{
|
||||||
@ -70,7 +225,7 @@ FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString Se
|
|||||||
return FullName.Left(MaxChar);
|
return FullName.Left(MaxChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
FString TruncatedName = Initial + FormattedLastName.Left(AvailableForLastName) + OverflowChars;
|
FString TruncatedName = Initial + FormattedLastName.Left(AvailableForLastName) + OverflowChar;
|
||||||
|
|
||||||
if (TruncatedName.Len() > MaxChar)
|
if (TruncatedName.Len() > MaxChar)
|
||||||
{
|
{
|
||||||
@ -79,70 +234,72 @@ FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString Se
|
|||||||
|
|
||||||
return TruncatedName;
|
return TruncatedName;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FString Separator,
|
FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FString& Separator,
|
||||||
const FString OverflowChar, const FString BibSeparator) const
|
const FString& OverflowChar, const FString& BibSeparator) const
|
||||||
{
|
{
|
||||||
FString BibText = FString::FromInt(Bib) + BibSeparator;
|
FString BibText = FString::FromInt(Bib) + BibSeparator;
|
||||||
FString FormattedName = GetFormattedName(MaxChar - BibText.Len(), Separator, OverflowChar);
|
int32 RemainingChars = MaxChar - BibText.Len();
|
||||||
|
|
||||||
|
if (RemainingChars <= 0)
|
||||||
|
{
|
||||||
|
return BibText.Left(MaxChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
FString FormattedName = GetFormattedName(RemainingChars, Separator, OverflowChar);
|
||||||
return BibText + FormattedName;
|
return BibText + FormattedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructeur privé depuis JSON
|
FText FDTFluxParticipant::GetFormattedNameText(const int MaxChar, const FString& Separator, const FString& OverflowChar) const
|
||||||
FDTFluxParticipant::FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject)
|
|
||||||
: Bib(JsonObject->GetIntegerField(TEXT("bib")))
|
|
||||||
, ContestId(JsonObject->GetIntegerField(TEXT("contestId")))
|
|
||||||
, Category(JsonObject->GetStringField(TEXT("category")))
|
|
||||||
, Club(JsonObject->GetStringField(TEXT("club")))
|
|
||||||
, Elite(JsonObject->GetBoolField(TEXT("elite")))
|
|
||||||
, Status(static_cast<EDTFluxParticipantStatusType>(JsonObject->GetIntegerField(TEXT("status"))))
|
|
||||||
, Team(JsonObject->GetStringField(TEXT("team")))
|
|
||||||
, bIsMassStartParticipant(false)
|
|
||||||
, CurrentSplit(-1)
|
|
||||||
{
|
{
|
||||||
UE_LOG(logDTFluxCore, Error, TEXT("Ctor with JSON Object"))
|
return FText::FromString(GetFormattedName(MaxChar, Separator, OverflowChar));
|
||||||
for (uint8 Index = 1; ; Index++)
|
|
||||||
{
|
|
||||||
FString FirstNameKey = Index == 1 ? "firstName" : FString::Printf(TEXT("firstName%i"), Index);
|
|
||||||
FString LastNameKey = Index == 1 ? "lastName" : FString::Printf(TEXT("lastName%i"), Index);
|
|
||||||
FString GenderKey = Index == 1 ? "gender" : FString::Printf(TEXT("gender%i"), Index);
|
|
||||||
// max 10 Persons
|
|
||||||
if (Index >= 10)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (!JsonObject->HasField(FirstNameKey) && !JsonObject->HasField(LastNameKey)
|
|
||||||
&& !JsonObject->HasField(GenderKey))
|
FText FDTFluxParticipant::GetConcatFormattedNameText(const int MaxChar, const FString& Separator,
|
||||||
|
const FString& OverflowChar, const FString& BibSeparator) const
|
||||||
{
|
{
|
||||||
UE_LOG(logDTFluxCore, Error, TEXT("No Corresponding Field!!!"))
|
return FText::FromString(GetConcatFormattedName(MaxChar, Separator, OverflowChar, BibSeparator));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
const FString FirstName = JsonObject->GetStringField(FirstNameKey);
|
|
||||||
const FString LastName = JsonObject->GetStringField(LastNameKey);
|
FString FDTFluxParticipant::GetFormattedName(const FDTFluxParticipant& Participant, const int MaxChar,
|
||||||
const FString Gender = JsonObject->GetStringField(GenderKey);
|
const FString& Separator, const FString& OverflowChar)
|
||||||
if (FirstName.IsEmpty() && LastName.IsEmpty())
|
{
|
||||||
continue;
|
return Participant.GetFormattedName(MaxChar, Separator, OverflowChar);
|
||||||
FDTFluxPerson Person;
|
|
||||||
Person.FirstName = FirstName;
|
|
||||||
Person.LastName = LastName;
|
|
||||||
Person.Gender = Gender;
|
|
||||||
Teammate.Add(Person);
|
|
||||||
}
|
}
|
||||||
UE_LOG(logDTFluxCore, Error, TEXT("Ctor with JSON Object Teammate is now %i long"), Teammate.Num());
|
|
||||||
|
FString FDTFluxParticipant::GetConcatFormattedName(const FDTFluxParticipant& Participant, const int MaxChar,
|
||||||
|
const FString& Separator, const FString& OverflowChar,
|
||||||
|
const FString& BibSeparator)
|
||||||
|
{
|
||||||
|
return Participant.GetConcatFormattedName(MaxChar, Separator, OverflowChar, BibSeparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
FText FDTFluxParticipant::GetFormattedNameText(const FDTFluxParticipant& Participant, const int MaxChar,
|
||||||
|
const FString& Separator, const FString& OverflowChar)
|
||||||
|
{
|
||||||
|
return Participant.GetFormattedNameText(MaxChar, Separator, OverflowChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
FText FDTFluxParticipant::GetConcatFormattedNameText(const FDTFluxParticipant& Participant, const int MaxChar,
|
||||||
|
const FString& Separator, const FString& OverflowChar,
|
||||||
|
const FString& BibSeparator)
|
||||||
|
{
|
||||||
|
return Participant.GetConcatFormattedNameText(MaxChar, Separator, OverflowChar, BibSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
FDTFluxParticipant FDTFluxParticipant::CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
FDTFluxParticipant FDTFluxParticipant::CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
||||||
{
|
{
|
||||||
|
if (!JsonObject.IsValid())
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxCore, Error, TEXT("Cannot create participant from invalid JSON object"));
|
||||||
|
return FDTFluxParticipant();
|
||||||
|
}
|
||||||
|
|
||||||
return FDTFluxParticipant(JsonObject);
|
return FDTFluxParticipant(JsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FDTFluxParticipant::GetTeammateNum() const
|
FDTFluxTeamStatusUpdate::FDTFluxTeamStatusUpdate(const int InBib, const int InStatus)
|
||||||
|
: Bib(InBib)
|
||||||
|
, Status(static_cast<EDTFluxParticipantStatusType>(InStatus))
|
||||||
{
|
{
|
||||||
return Teammate.Num();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FDTFluxParticipant::IsTeam() const
|
|
||||||
{
|
|
||||||
return Teammate.Num() < 1;
|
|
||||||
}
|
}
|
||||||
@ -89,68 +89,6 @@ public:
|
|||||||
bool GetStage(const int StageID, FDTFluxStage& OutStage) const;
|
bool GetStage(const int StageID, FDTFluxStage& OutStage) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool FDTFluxContest::IsFinished() const
|
|
||||||
{
|
|
||||||
return EndTime <= FDateTime::Now();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void FDTFluxContest::UpdateEndTime()
|
|
||||||
{
|
|
||||||
TArray<FDTFluxStage> TempStages = Stages;
|
|
||||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
|
||||||
{
|
|
||||||
return A.EndTime < B.EndTime;
|
|
||||||
});
|
|
||||||
EndTime = TempStages.Last().EndTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int FDTFluxContest::GetLastStageId()
|
|
||||||
{
|
|
||||||
if (LastStageId <= 0)
|
|
||||||
{
|
|
||||||
UpdateLastStageId();
|
|
||||||
}
|
|
||||||
return LastStageId;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void FDTFluxContest::UpdateLastStageId()
|
|
||||||
{
|
|
||||||
TArray<FDTFluxStage> TempStages = Stages;
|
|
||||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
|
||||||
{
|
|
||||||
return A.StageId < B.StageId;
|
|
||||||
});
|
|
||||||
LastStageId = TempStages.Last().StageId;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline FDTFluxStage& FDTFluxContest::GetLastStage() const
|
|
||||||
{
|
|
||||||
TArray<FDTFluxStage> TempStages = Stages;
|
|
||||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
|
||||||
{
|
|
||||||
return A.StageId < B.StageId;
|
|
||||||
});
|
|
||||||
return TempStages.Last();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool FDTFluxContest::GetStage(const int StageID, FDTFluxStage& OutStage) const
|
|
||||||
{
|
|
||||||
if (Stages.Num() == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (const FDTFluxStage& Stage : Stages)
|
|
||||||
{
|
|
||||||
if (Stage.StageId == StageID)
|
|
||||||
{
|
|
||||||
OutStage = Stage;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
USTRUCT()
|
USTRUCT()
|
||||||
struct DTFLUXCORE_API FDTFluxRaceData
|
struct DTFLUXCORE_API FDTFluxRaceData
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,6 +7,10 @@
|
|||||||
#include "Types/Enum/DTFluxModelEnums.h"
|
#include "Types/Enum/DTFluxModelEnums.h"
|
||||||
#include "DTFluxTeamListStruct.generated.h"
|
#include "DTFluxTeamListStruct.generated.h"
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class UDTFluxModelAsset;
|
||||||
|
class UDTFluxParticipantFactory;
|
||||||
|
|
||||||
USTRUCT()
|
USTRUCT()
|
||||||
struct DTFLUXCORE_API FDTFluxTeamListItemDefinition
|
struct DTFLUXCORE_API FDTFluxTeamListItemDefinition
|
||||||
{
|
{
|
||||||
@ -15,76 +19,78 @@ struct DTFLUXCORE_API FDTFluxTeamListItemDefinition
|
|||||||
public:
|
public:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString Type = "team-list-item";
|
FString Type = "team-list-item";
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
int ContestId;
|
int ContestId = 0;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
int Bib;
|
int Bib = 0;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString FirstName;
|
FString FirstName;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString LastName;
|
FString LastName;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString FirstName2 = "";
|
FString FirstName2 = "";
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString LastName2 = "";
|
FString LastName2 = "";
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString Team = "";
|
FString Team = "";
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString Gender;
|
FString Gender;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString Gender2;
|
FString Gender2;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
bool Elite;
|
bool Elite = false;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString Category;
|
FString Category;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
int Status;
|
int Status = 0;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString Club;
|
FString Club;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
USTRUCT(BlueprintType, Category="DTFlux|Model")
|
USTRUCT(BlueprintType, Category="DTFlux|Model")
|
||||||
struct DTFLUXCORE_API FDTFluxPerson
|
struct DTFLUXCORE_API FDTFluxPerson
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString FirstName;
|
FString FirstName;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString LastName;
|
FString LastName;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString Gender;
|
FString Gender;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString FunctionLine1 = TEXT("");
|
FString FunctionLine1 = TEXT("");
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString FunctionLine2 = TEXT("");
|
FString FunctionLine2 = TEXT("");
|
||||||
|
|
||||||
bool operator==(const FDTFluxPerson& Right) const
|
bool operator==(const FDTFluxPerson& Right) const;
|
||||||
{
|
bool operator!=(const FDTFluxPerson& Right) const;
|
||||||
return FirstName.ToLower() + LastName.ToLower() + Gender.ToLower()
|
bool operator==(const int Length) const;
|
||||||
== Right.FirstName.ToLower() + Right.LastName.ToLower() + Right.Gender.ToLower();
|
bool operator!=(const int Length) const;
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const int Length) const
|
FString GetNormalizedString() const;
|
||||||
{
|
|
||||||
return (FirstName.ToLower() + LastName.ToLower() + Gender.ToLower()).Len() == Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const int Length) const
|
bool IsValid() const;
|
||||||
{
|
|
||||||
return !(*this == Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const FDTFluxPerson& Right) const
|
|
||||||
{
|
|
||||||
return FirstName.ToLower() + LastName.ToLower() + Gender.ToLower()
|
|
||||||
!= Right.FirstName.ToLower() + Right.LastName.ToLower() + Right.Gender.ToLower();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
USTRUCT(BlueprintType, Category="DTFlux|Model")
|
USTRUCT(BlueprintType, Category="DTFlux|Model")
|
||||||
struct DTFLUXCORE_API FDTFluxParticipant
|
struct DTFLUXCORE_API FDTFluxParticipant
|
||||||
{
|
{
|
||||||
@ -94,129 +100,98 @@ struct DTFLUXCORE_API FDTFluxParticipant
|
|||||||
friend class UDTFluxParticipantFactory;
|
friend class UDTFluxParticipantFactory;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructeur public par défaut requis par Unreal
|
FDTFluxParticipant();
|
||||||
FDTFluxParticipant()
|
|
||||||
: Bib(-1)
|
|
||||||
, ContestId(-1)
|
|
||||||
, Elite(false)
|
|
||||||
, Status(static_cast<EDTFluxParticipantStatusType>(0))
|
|
||||||
, bIsMassStartParticipant(false)
|
|
||||||
, CurrentSplit(-1)
|
|
||||||
{
|
|
||||||
Teammate.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", EditAnywhere)
|
||||||
/**
|
|
||||||
* Vérifie si le participant est dans son état par défaut (non initialisé)
|
|
||||||
* @return True si tous les champs sont à leur valeur par défaut
|
|
||||||
*/
|
|
||||||
bool IsDefault() const
|
|
||||||
{
|
|
||||||
return Bib == -1
|
|
||||||
&& ContestId == -1
|
|
||||||
&& Category.IsEmpty()
|
|
||||||
&& Club.IsEmpty()
|
|
||||||
&& !Elite
|
|
||||||
&& Status == static_cast<EDTFluxParticipantStatusType>(0)
|
|
||||||
&& Team.IsEmpty()
|
|
||||||
&& !bIsMassStartParticipant
|
|
||||||
&& CurrentSplit == -1
|
|
||||||
&& Teammate.IsEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
|
|
||||||
int Bib = -1;
|
int Bib = -1;
|
||||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", EditAnywhere)
|
||||||
int ContestId = -1;
|
int ContestId = -1;
|
||||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString Category;
|
FString Category;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString Club;
|
FString Club;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
|
||||||
bool Elite;
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
bool Elite = false;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
EDTFluxParticipantStatusType Status;
|
EDTFluxParticipantStatusType Status;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString Team;
|
FString Team;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
bool bIsMassStartParticipant = false;
|
bool bIsMassStartParticipant = false;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||||
int CurrentSplit = -1;
|
int CurrentSplit = -1;
|
||||||
|
|
||||||
// void Dump() const;
|
bool IsDefault() const;
|
||||||
|
|
||||||
void AddTeammate(const FDTFluxPerson& Person);
|
void AddTeammate(const FDTFluxPerson& Person);
|
||||||
void AddTeammate(const FString LastName, const FString FirstName, const FString Gender);
|
void AddTeammate(const FString& LastName, const FString& FirstName, const FString& Gender);
|
||||||
|
|
||||||
FText GetFormattedNameText(const int MaxChar = 15, const FString Separator = FString(". "),
|
int GetTeammateNum() const;
|
||||||
const FString OverflowChar = FString("...")) const
|
|
||||||
{
|
|
||||||
return FText::FromString(GetFormattedName(MaxChar, OverflowChar));
|
|
||||||
};
|
|
||||||
|
|
||||||
FText GetConcatFormattedNameText(const int MaxChar = 20, const FString Separator = FString(". "),
|
bool IsTeam() const;
|
||||||
const FString OverflowChar = FString("..."),
|
|
||||||
const FString BibSeparator = FString(". ")) const
|
|
||||||
{
|
|
||||||
return FText::FromString(GetConcatFormattedName(MaxChar, Separator, OverflowChar, BibSeparator));
|
|
||||||
};
|
|
||||||
FString GetFormattedName(const int MaxChar = 15, const FString Separator = FString(". "),
|
|
||||||
const FString OverflowChar = FString("...")) const;
|
|
||||||
FString GetConcatFormattedName(const int MaxChar = 20, const FString Separator = FString(". "),
|
|
||||||
const FString OverflowChar = FString("..."),
|
|
||||||
const FString BibSeparator = FString(". ")) const;
|
|
||||||
|
|
||||||
static FString GetFormattedName(const FDTFluxParticipant& Participant, const int MaxChar = 15,
|
|
||||||
const FString Separator = FString(". "),
|
|
||||||
const FString OverflowChar = FString("..."))
|
|
||||||
{
|
|
||||||
return Participant.GetFormattedName(MaxChar, Separator, OverflowChar);
|
|
||||||
};
|
|
||||||
|
|
||||||
static FString GetConcatFormattedName(const FDTFluxParticipant& Participant, const int MaxChar = 15,
|
const TArray<FDTFluxPerson>& GetTeammate() const;
|
||||||
const FString Separator = FString(". "),
|
|
||||||
const FString OverflowChar = FString("..."),
|
|
||||||
const FString BibSeparator = FString(". "))
|
|
||||||
{
|
|
||||||
return Participant.GetConcatFormattedName(MaxChar, Separator, OverflowChar, BibSeparator);
|
|
||||||
};
|
|
||||||
|
|
||||||
static FText GetFormattedNameText(const FDTFluxParticipant& Participant, const int MaxChar = 15,
|
FString GetFormattedName(const int MaxChar = 15,
|
||||||
const FString Separator = FString(". "),
|
const FString& Separator = FString(". "),
|
||||||
const FString OverflowChar = FString("..."))
|
const FString& OverflowChar = FString("...")) const;
|
||||||
{
|
|
||||||
return Participant.GetFormattedNameText(MaxChar, Separator, OverflowChar);
|
|
||||||
};
|
|
||||||
|
|
||||||
static FText GetConcatFormattedNameText(const FDTFluxParticipant& Participant, const int MaxChar = 15,
|
FString GetConcatFormattedName(const int MaxChar = 20,
|
||||||
const FString Separator = FString(". "),
|
const FString& Separator = FString(". "),
|
||||||
const FString OverflowChar = FString("..."),
|
const FString& OverflowChar = FString("..."),
|
||||||
const FString BibSeparator = FString(". "))
|
const FString& BibSeparator = FString(". ")) const;
|
||||||
{
|
|
||||||
return Participant.GetConcatFormattedNameText(MaxChar, Separator, OverflowChar, BibSeparator);
|
|
||||||
};
|
|
||||||
const TArray<FDTFluxPerson> GetTeammate() const { return Teammate; }
|
|
||||||
|
|
||||||
private:
|
FText GetFormattedNameText(const int MaxChar = 15,
|
||||||
// --- Constructeur privé ---
|
const FString& Separator = FString(". "),
|
||||||
explicit FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject);
|
const FString& OverflowChar = FString("...")) const;
|
||||||
|
|
||||||
|
FText GetConcatFormattedNameText(const int MaxChar = 20,
|
||||||
|
const FString& Separator = FString(". "),
|
||||||
|
const FString& OverflowChar = FString("..."),
|
||||||
|
const FString& BibSeparator = FString(". ")) const;
|
||||||
|
|
||||||
|
static FString GetFormattedName(const FDTFluxParticipant& Participant,
|
||||||
|
const int MaxChar = 15,
|
||||||
|
const FString& Separator = FString(". "),
|
||||||
|
const FString& OverflowChar = FString("..."));
|
||||||
|
|
||||||
|
static FString GetConcatFormattedName(const FDTFluxParticipant& Participant,
|
||||||
|
const int MaxChar = 15,
|
||||||
|
const FString& Separator = FString(". "),
|
||||||
|
const FString& OverflowChar = FString("..."),
|
||||||
|
const FString& BibSeparator = FString(". "));
|
||||||
|
|
||||||
|
static FText GetFormattedNameText(const FDTFluxParticipant& Participant,
|
||||||
|
const int MaxChar = 15,
|
||||||
|
const FString& Separator = FString(". "),
|
||||||
|
const FString& OverflowChar = FString("..."));
|
||||||
|
|
||||||
|
static FText GetConcatFormattedNameText(const FDTFluxParticipant& Participant,
|
||||||
|
const int MaxChar = 15,
|
||||||
|
const FString& Separator = FString(". "),
|
||||||
|
const FString& OverflowChar = FString("..."),
|
||||||
|
const FString& BibSeparator = FString(". "));
|
||||||
|
|
||||||
|
static FDTFluxParticipant CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY(Category="DTFlux|model", VisibleAnywhere)
|
UPROPERTY(Category="DTFlux|Model", VisibleAnywhere)
|
||||||
TArray<FDTFluxPerson> Teammate;
|
TArray<FDTFluxPerson> Teammate;
|
||||||
// Méthode publique pour construire à partir d'un JSON (utilisée par la factory)
|
|
||||||
static FDTFluxParticipant CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject);
|
private:
|
||||||
int GetTeammateNum() const;
|
explicit FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject);
|
||||||
bool IsTeam() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct FDTFluxTeamListDefinition
|
|
||||||
* Struct representing the Participant List definition
|
|
||||||
* Used to exchange data between Objects in the system
|
|
||||||
*/
|
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
struct DTFLUXCORE_API FDTFluxTeamListDefinition
|
struct DTFLUXCORE_API FDTFluxTeamListDefinition
|
||||||
{
|
{
|
||||||
@ -224,27 +199,22 @@ struct DTFLUXCORE_API FDTFluxTeamListDefinition
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
// ReSharper disable once IdentifierTypo
|
|
||||||
TArray<FDTFluxParticipant> Participants;
|
TArray<FDTFluxParticipant> Participants;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
struct FDTFluxTeamStatusUpdate
|
struct DTFLUXCORE_API FDTFluxTeamStatusUpdate
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FDTFluxTeamStatusUpdate() = default;
|
FDTFluxTeamStatusUpdate() = default;
|
||||||
|
FDTFluxTeamStatusUpdate(const int InBib, const int InStatus);
|
||||||
FDTFluxTeamStatusUpdate(const int InBib, const int InStatus)
|
|
||||||
: Bib(InBib)
|
|
||||||
, Status(static_cast<EDTFluxParticipantStatusType>(InStatus))
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Participant")
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Participant")
|
||||||
int Bib = -1;
|
int Bib = -1;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Participant")
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Participant")
|
||||||
EDTFluxParticipantStatusType Status = EDTFluxParticipantStatusType::Unknown;
|
EDTFluxParticipantStatusType Status = EDTFluxParticipantStatusType::Unknown;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user