Ranking reforge. SplitRanking is not implemented yet !!!
This commit is contained in:
@ -6,37 +6,6 @@
|
|||||||
#include "Types/Objects/DTFluxContestStorage.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)
|
UDTFluxModelAsset::UDTFluxModelAsset(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -93,3 +62,47 @@ bool UDTFluxModelAsset::PersonExists(const FDTFluxPerson& InPerson) const
|
|||||||
return Person == InPerson;
|
return Person == InPerson;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@ -99,17 +99,17 @@ void UDTFluxContestStorage::AddSplit(const int InContest, const FDTFluxSplit& In
|
|||||||
|
|
||||||
#pragma region SplitRankingRegion
|
#pragma region SplitRankingRegion
|
||||||
|
|
||||||
void UDTFluxContestStorage::AddSplitRanking(const int InContest, const FDTFluxSplitRanking& InSplitRanking)
|
void UDTFluxContestStorage::AddSplitRanking(const int InContest, const FDTFluxStageRanking& InSplitRanking)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDTFluxContestStorage::GetSplitRankingByParticipant(const FDTFluxParticipant& InParticipant, const int InContestId,
|
void UDTFluxContestStorage::GetSplitRankingByParticipant(const FDTFluxParticipant& InParticipant, const int InContestId,
|
||||||
const int InStageId, const FDTFluxSplitRanking& OutSplitRankingForBib)
|
const int InStageId, const FDTFluxStageRanking& OutSplitRankingForBib)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDTFluxContestStorage::GetSplitRankingByBib(const int InBib, const int InContestId, const int InStageId,
|
void UDTFluxContestStorage::GetSplitRankingByBib(const int InBib, const int InContestId, const int InStageId,
|
||||||
const FDTFluxSplitRanking& OutSplitRankingForBib)
|
const FDTFluxStageRanking& OutSplitRankingForBib)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,10 @@ void FDTFluxStageRanking::Dump() const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FDTFluxSplitRanking::Dump() const
|
// void FDTFluxSplitRanking::Dump() const
|
||||||
{
|
// {
|
||||||
UE_LOG(logDTFluxCore, Log, TEXT("SplitGapItem"))
|
// UE_LOG(logDTFluxCore, Log, TEXT("SplitGapItem"))
|
||||||
// Participant.Dump();
|
// // Participant.Dump();
|
||||||
UE_LOG(logDTFluxCore, Log, TEXT("Bib %02d Rank %02d Gap %s Time %s"), Bib, Rank, *Gap, *Time);
|
// UE_LOG(logDTFluxCore, Log, TEXT("Bib %02d Rank %02d Gap %s Time %s"), Bib, Rank, *Gap, *Time);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|||||||
@ -34,10 +34,13 @@ public:
|
|||||||
TMap<FString /* ContestName */, FDTFluxContest> Contests;
|
TMap<FString /* ContestName */, FDTFluxContest> Contests;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||||
TArray<FDTFluxContestRanking> ContestRankings;
|
TMap<int /*ContestId*/, FDTFluxContestRankings> ContestRankings;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||||
TMap<FString /*ContestName*/ ,FDTFluxStageRanking> StageRankings;
|
TArray<FDTFluxStageRankings> StageRankings;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||||
|
TArray<FDTFluxStageRankings> SplitRankings;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|ModelAsset")
|
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|ModelAsset")
|
||||||
void AddContest(const FDTFluxContest &Contest);
|
void AddContest(const FDTFluxContest &Contest);
|
||||||
@ -51,6 +54,18 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|Participant")
|
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|Participant")
|
||||||
void AddParticipant(const FDTFluxParticipant& InParticipant, const int ContestId);
|
void AddParticipant(const FDTFluxParticipant& InParticipant, const int ContestId);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|Person")
|
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|Person|Utils")
|
||||||
bool PersonExists(const FDTFluxPerson& InPerson) const;
|
bool PersonExists(const FDTFluxPerson& InPerson) const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
|
||||||
|
FString GetContestNameForId(const int InContestID);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
|
||||||
|
bool UpdateStageRanking(const FDTFluxStageRankings& InStageRankings);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
|
||||||
|
bool UpdateSplitRanking(const FDTFluxStageRankings& InStageRankings);
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void AddContestRanking(const FDTFluxContestRankings& NewContestRankings);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -88,13 +88,13 @@ public:
|
|||||||
void AddSplit(const int InContest, const FDTFluxSplit& InSplit);
|
void AddSplit(const int InContest, const FDTFluxSplit& InSplit);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
|
||||||
void AddSplitRanking(const int InContest, const FDTFluxSplitRanking& InSplitRanking);
|
void AddSplitRanking(const int InContest, const FDTFluxStageRanking& InSplitRanking);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
|
||||||
void GetSplitRankingByParticipant(const FDTFluxParticipant& InParticipant, const int InContestId, const int InStageId, const FDTFluxSplitRanking& OutSplitRankingForBib);
|
void GetSplitRankingByParticipant(const FDTFluxParticipant& InParticipant, const int InContestId, const int InStageId, const FDTFluxStageRanking& OutSplitRankingForBib);
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest")
|
||||||
void GetSplitRankingByBib(const int InBib, const int InContestId, const int InStageId, const FDTFluxSplitRanking& OutSplitRankingForBib);
|
void GetSplitRankingByBib(const int InBib, const int InContestId, const int InStageId, const FDTFluxStageRanking& OutSplitRankingForBib);
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma region ParticipantSection
|
#pragma region ParticipantSection
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public:
|
|||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||||
int Bib = -1;
|
int Bib = -1;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||||
FDTFluxSplitRanking SplitRanking;
|
FDTFluxStageRanking SplitRanking;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||||
FDTFluxStageRanking StageRanking;
|
FDTFluxStageRanking StageRanking;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public:
|
|||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||||
FString Name;
|
FString Name;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||||
TArray<FDTFluxSplitRanking> SplitRankings;
|
TArray<FDTFluxStageRanking> SplitRankings;
|
||||||
// void Dump() const;
|
// void Dump() const;
|
||||||
// // void InsertOrReplace(const FDTFluxStageRankingResponseItem& SplitRankingItemResp);
|
// // void InsertOrReplace(const FDTFluxStageRankingResponseItem& SplitRankingItemResp);
|
||||||
// void SortByRank();
|
// void SortByRank();
|
||||||
|
|||||||
@ -16,25 +16,43 @@ struct DTFLUXCORE_API FDTFluxContestRanking
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
int Bib;
|
int Bib;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
int Rank;
|
int Rank;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FString Gap;
|
FString Gap;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FString Time;
|
FString Time;
|
||||||
UPROPERTY();
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere);
|
||||||
FString SpeedSwimAverage;
|
FString SpeedSwimAverage;
|
||||||
UPROPERTY();
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere);
|
||||||
FString SpeedRunningAverage;
|
FString SpeedRunningAverage;
|
||||||
UPROPERTY();
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere);
|
||||||
FString SpeedTotalAverage;
|
FString SpeedTotalAverage;
|
||||||
void Dump () const;
|
void Dump () const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
USTRUCT(BlueprintType)
|
||||||
|
struct FDTFluxContestRankings
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||||
|
TArray<FDTFluxContestRanking> Rankings;
|
||||||
|
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||||
|
int ContestId;
|
||||||
|
//TODO check if necessary ???
|
||||||
|
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||||
|
FString ContestName;
|
||||||
|
|
||||||
|
void SetName(const FString Name)
|
||||||
|
{
|
||||||
|
ContestName = Name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct FDTFluxStageRanking
|
* @struct FDTFluxStageRanking
|
||||||
* Representing a stage ranking for a participant
|
* Representing a stage ranking for a participant
|
||||||
@ -44,59 +62,48 @@ struct DTFLUXCORE_API FDTFluxStageRanking
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
int Bib;
|
int Bib;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
int Rank;
|
int Rank;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FString Gap;
|
FString Gap;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FString Time;
|
FString Time;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FString TimeSwim;
|
FString TimeSwim;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FString TimeTransition;
|
FString TimeTransition;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FString TimeRun;
|
FString TimeRun;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FString TimeStart;
|
FString TimeStart;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
FDateTime StartTime;
|
FDateTime StartTime;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
float SpeedRunning;
|
float SpeedRunning;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
float SpeedTotal;
|
float SpeedTotal;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||||
float SpeedSwim;
|
float SpeedSwim;
|
||||||
void Dump() const;
|
void Dump() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
USTRUCT(BlueprintType)
|
||||||
* @struct FDTFluxSplitRanking
|
struct FDTFluxStageRankings
|
||||||
* Representing a ranking of a participant in a split
|
|
||||||
*/
|
|
||||||
USTRUCT(BlueprintType, Category="DTFlux|Model")
|
|
||||||
struct DTFLUXCORE_API FDTFluxSplitRanking
|
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||||
int Bib;
|
TArray<FDTFluxStageRanking> Rankings;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||||
int ContestId = 0;
|
int ContestId;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||||
int StageId = 0;
|
int StageId;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
|
||||||
int SplitId = 0;
|
int SplitId;
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
|
||||||
FString Gap;
|
};
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
|
||||||
FString Time;
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
|
||||||
int Rank = 0;
|
|
||||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
|
||||||
bool Display = false;
|
|
||||||
void Dump() const;
|
|
||||||
|
|
||||||
};
|
|
||||||
@ -46,10 +46,11 @@ void UDTFluxCoreSubsystem::RegisterDelegates()
|
|||||||
{
|
{
|
||||||
NetworkSubsystem->OnReceivedRaceData().AddDynamic(this, &UDTFluxCoreSubsystem::ParseRaceData);
|
NetworkSubsystem->OnReceivedRaceData().AddDynamic(this, &UDTFluxCoreSubsystem::ParseRaceData);
|
||||||
NetworkSubsystem->OnReceivedTeamList().AddDynamic(this, &UDTFluxCoreSubsystem::ParseTeamList);
|
NetworkSubsystem->OnReceivedTeamList().AddDynamic(this, &UDTFluxCoreSubsystem::ParseTeamList);
|
||||||
|
NetworkSubsystem->OnReceivedContestRanking().AddDynamic(this, &UDTFluxCoreSubsystem::ParseContestRanking);
|
||||||
|
NetworkSubsystem->OnReceivedStageRanking().BindUFunction(this, "ParseStageOrSplitRanking");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UDTFluxCoreSubsystem::ParseRaceData(const FDTFluxRaceData& RaceDataDefinition)
|
void UDTFluxCoreSubsystem::ParseRaceData(const FDTFluxRaceData& RaceDataDefinition)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -99,6 +100,31 @@ void UDTFluxCoreSubsystem::ParseTeamList(const FDTFluxTeamListDefinition& TeamLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDTFluxCoreSubsystem::ParseContestRanking(const FDTFluxContestRankings& ContestRankings)
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Received ContestRankings with %i Items"), ContestRankings.Rankings.Num());
|
||||||
|
FDTFluxContestRankings NewContestRankings = ContestRankings;
|
||||||
|
NewContestRankings.SetName( DataStorage->GetContestNameForId(ContestRankings.ContestId));
|
||||||
|
DataStorage->AddContestRanking(NewContestRankings);
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestRankings added for Contest %s"), *NewContestRankings.ContestName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDTFluxCoreSubsystem::ParseStageOrSplitRanking(const FDTFluxStageRankings& StageOrSplitRankings)
|
||||||
|
{
|
||||||
|
if(StageOrSplitRankings.SplitId == -1)
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Received StageRankings with %i Items"), StageOrSplitRankings.Rankings.Num());
|
||||||
|
if(!DataStorage->UpdateStageRanking(StageOrSplitRankings))
|
||||||
|
{
|
||||||
|
DataStorage->StageRankings.Add(StageOrSplitRankings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Received SplitRankings with %i Items"), StageOrSplitRankings.Rankings.Num());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UDTFluxCoreSubsystem::OnDataReceived()
|
void UDTFluxCoreSubsystem::OnDataReceived()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -111,7 +137,6 @@ void UDTFluxCoreSubsystem::SendRequest(const FString& Message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UDTFluxCoreSubsystem::SendTeamListRequest()
|
void UDTFluxCoreSubsystem::SendTeamListRequest()
|
||||||
{
|
{
|
||||||
if (NetworkSubsystem)
|
if (NetworkSubsystem)
|
||||||
@ -166,3 +191,5 @@ void UDTFluxCoreSubsystem::RefreshStorage()
|
|||||||
{
|
{
|
||||||
// TODO Implement this
|
// TODO Implement this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
// TSharedPtr<FDTFluxParser> Parser;
|
// TSharedPtr<FDTFluxParser> Parser;
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitRankings, FDateTime, ReceivedAt, TArray<FDTFluxSplitRanking>, SplitRankings);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitRankings, FDateTime, ReceivedAt, TArray<FDTFluxStageRanking>, SplitRankings);
|
||||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||||
FOnSplitRankings OnSplitRankings;
|
FOnSplitRankings OnSplitRankings;
|
||||||
|
|
||||||
@ -97,6 +97,10 @@ private:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void ParseTeamList(const FDTFluxTeamListDefinition& TeamListDefinition);
|
void ParseTeamList(const FDTFluxTeamListDefinition& TeamListDefinition);
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
|
void ParseContestRanking(const FDTFluxContestRankings& ContestRankings);
|
||||||
|
UFUNCTION()
|
||||||
|
void ParseStageOrSplitRanking(const FDTFluxStageRankings& StageOrSplitRankings);
|
||||||
|
UFUNCTION()
|
||||||
void OnDataReceived();
|
void OnDataReceived();
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void SendRequest(const FString& Message);
|
void SendRequest(const FString& Message);
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include "Struct/DTFluxServerResponseStruct.h"
|
#include "Struct/DTFluxServerResponseStruct.h"
|
||||||
#include "Struct/DTFluxRequestStructs.h"
|
#include "Struct/DTFluxRequestStructs.h"
|
||||||
#include "Struct/DTFluxRaceDataServerResponse.h"
|
#include "Struct/DTFluxRaceDataServerResponse.h"
|
||||||
|
#include "Struct/DTFluxRankingServerResponse.h"
|
||||||
#include "Struct/DTFluxTeamListServerResponse.h"
|
#include "Struct/DTFluxTeamListServerResponse.h"
|
||||||
#include "Types/Struct/DTFluxRaceDataStructs.h"
|
#include "Types/Struct/DTFluxRaceDataStructs.h"
|
||||||
|
|
||||||
@ -192,6 +193,7 @@ void UFDTFluxNetworkSubsystem::OnWebSocketClosedEvent_Subsystem(int32 StatusCode
|
|||||||
*WsClient->GetAddress(), *Reason, StatusCode, bWasClean ? TEXT("True") : TEXT("False"));
|
*WsClient->GetAddress(), *Reason, StatusCode, bWasClean ? TEXT("True") : TEXT("False"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO reforge API to keep track of Requests
|
||||||
void UFDTFluxNetworkSubsystem::OnWebSocketMessageEvent_Subsystem(const FString& MessageString)
|
void UFDTFluxNetworkSubsystem::OnWebSocketMessageEvent_Subsystem(const FString& MessageString)
|
||||||
{
|
{
|
||||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws %s :\nMessage Received : %s"), *WsClient->GetAddress(), *MessageString);
|
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws %s :\nMessage Received : %s"), *WsClient->GetAddress(), *MessageString);
|
||||||
@ -265,8 +267,41 @@ void UFDTFluxNetworkSubsystem::OnWebSocketMessageEvent_Subsystem(const FString&
|
|||||||
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws Team-List Data Sent"));
|
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws Team-List Data Sent"));
|
||||||
return OnTeamListReceived.Broadcast(TeamListDefinition);
|
return OnTeamListReceived.Broadcast(TeamListDefinition);
|
||||||
}
|
}
|
||||||
|
if(Response.Type.Contains("contest-ranking"))
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws Contest-Ranking Data"));
|
||||||
|
FDTFluxContestRankingResponse ContestRankingResponse;
|
||||||
|
FJsonObjectConverter::JsonObjectStringToUStruct<FDTFluxContestRankingResponse>(Response.RawMessage, &ContestRankingResponse);
|
||||||
|
FDTFluxContestRankings ContestRankings;
|
||||||
|
ContestRankings.ContestId = ContestRankingResponse.ContestID;
|
||||||
|
for(auto& RankingItem : ContestRankingResponse.Datas)
|
||||||
|
{
|
||||||
|
FDTFluxContestRanking Temp = RankingItem;
|
||||||
|
ContestRankings.Rankings.Add(Temp);
|
||||||
|
}
|
||||||
|
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws ContestRanking Data Sent for Contest %i"), ContestRankings.ContestId);
|
||||||
|
return OnContestRankingReceived.Broadcast(ContestRankings);
|
||||||
|
}
|
||||||
|
if(Response.Type.Contains("stage-ranking") )
|
||||||
|
{
|
||||||
|
// StageRanking
|
||||||
|
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws Stage-Ranking Data"));
|
||||||
|
FDTFluxStageRankingResponse StageRankingResponse;
|
||||||
|
FJsonObjectConverter::JsonObjectStringToUStruct<FDTFluxStageRankingResponse>(Response.RawMessage, &StageRankingResponse);
|
||||||
|
FDTFluxStageRankings StageRankings;
|
||||||
|
StageRankings.ContestId = StageRankingResponse.ContestId;
|
||||||
|
StageRankings.StageId = StageRankingResponse.StageId;
|
||||||
|
StageRankings.SplitId = StageRankingResponse.SplitId;
|
||||||
|
for(FDTFluxStageRanking& InRanking : StageRankingResponse.Datas)
|
||||||
|
{
|
||||||
|
FDTFluxStageRanking Temp = InRanking;
|
||||||
|
StageRankings.Rankings.Add(InRanking);
|
||||||
|
}
|
||||||
|
UE_LOG(logDTFluxNetwork, Warning, TEXT("Ws StageRanking Data Sent for Contest %i and Stage %i\n[Result] : %s"),
|
||||||
|
StageRankings.ContestId, StageRankings.StageId, OnStageRankingReceived.ExecuteIfBound(StageRankings) ? TEXT("Executed") : TEXT("Not Bound !!!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
UE_LOG(logDTFluxNetwork, Error, TEXT("Ws %s :\nMessage Cannot be Parsed\n%s"), *WsClient->GetAddress(), *MessageString);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
UE_LOG(logDTFluxNetwork, Error, TEXT("Ws %s :\nMessage Received : %s Cannot be Parsed"), *WsClient->GetAddress(), *MessageString);
|
UE_LOG(logDTFluxNetwork, Error, TEXT("Ws %s :\nMessage Received : %s Cannot be Parsed"), *WsClient->GetAddress(), *MessageString);
|
||||||
|
|||||||
@ -43,20 +43,16 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
struct DTFLUXNETWORK_API FDTFluxStageRankingResponse
|
struct DTFLUXNETWORK_API FDTFluxStageRankingResponse : public FDTFluxStageRankings
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
FString Type = "stage-ranking";
|
FString Type = "stage-ranking";
|
||||||
UPROPERTY()
|
|
||||||
int ContestID;
|
|
||||||
UPROPERTY()
|
|
||||||
int StageID;
|
|
||||||
UPROPERTY()
|
|
||||||
int SplitID = -1;
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
// ReSharper disable once IdentifierTypo
|
// ReSharper disable once IdentifierTypo
|
||||||
TArray<FDTFluxStageRankingResponseItem> Datas;
|
TArray<FDTFluxStageRankingResponseItem> Datas;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include "Subsystems/EngineSubsystem.h"
|
#include "Subsystems/EngineSubsystem.h"
|
||||||
#include "Types/DTFluxNetworkSettingsTypes.h"
|
#include "Types/DTFluxNetworkSettingsTypes.h"
|
||||||
#include "Types/Enum/DTfluxCoreEnum.h"
|
#include "Types/Enum/DTfluxCoreEnum.h"
|
||||||
|
#include "Types/Struct/DTFluxRankingStructs.h"
|
||||||
#include "DTFluxNetworkSubsystem.generated.h"
|
#include "DTFluxNetworkSubsystem.generated.h"
|
||||||
|
|
||||||
|
|
||||||
@ -46,6 +47,22 @@ public:
|
|||||||
return OnTeamListReceived;
|
return OnTeamListReceived;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DECLARE_DELEGATE_OneParam(FOnStageRankingReceived, const FDTFluxStageRankings&);
|
||||||
|
FOnStageRankingReceived OnStageRankingReceived;
|
||||||
|
FOnStageRankingReceived& OnReceivedStageRanking()
|
||||||
|
{
|
||||||
|
return OnStageRankingReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnContestRankingReceived, const FDTFluxContestRankings&, ContestRankings);
|
||||||
|
FOnContestRankingReceived OnContestRankingReceived;
|
||||||
|
FOnContestRankingReceived& OnReceivedContestRanking()
|
||||||
|
{
|
||||||
|
return OnContestRankingReceived;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Network")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Network")
|
||||||
void Connect();
|
void Connect();
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user