adding Helpers GetCurrentStage GetCurrentContest GetCurrentStageName
This commit is contained in:
@ -26,3 +26,60 @@ EDTFluxStageStatusType UDTFluxModelHelper::GetStatusType(const int ContestID, co
|
|||||||
}
|
}
|
||||||
return StageStatus;
|
return StageStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UDTFluxModelHelper::GetCurrentContest(UDTFluxDataStorage* DataStorage)
|
||||||
|
{
|
||||||
|
int ContestId = -1;
|
||||||
|
FDateTime Now = FDateTime::Now();
|
||||||
|
for(const auto& Contest : DataStorage->Contests)
|
||||||
|
{
|
||||||
|
for(const auto& Stage : Contest.Stages)
|
||||||
|
{
|
||||||
|
// Stage has begun
|
||||||
|
if(Stage.StartTime <= Now)
|
||||||
|
{
|
||||||
|
return Contest.Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ContestId;
|
||||||
|
}
|
||||||
|
|
||||||
|
TArray<int> UDTFluxModelHelper::GetCurrentStage(UDTFluxDataStorage* DataStorage)
|
||||||
|
{
|
||||||
|
TArray<int> ContestAndStageId;
|
||||||
|
FDateTime Now = FDateTime::Now();
|
||||||
|
for(const auto& Contest : DataStorage->Contests)
|
||||||
|
{
|
||||||
|
for(const auto& Stage : Contest.Stages)
|
||||||
|
{
|
||||||
|
// Stage has begun
|
||||||
|
if(Stage.StartTime <= Now)
|
||||||
|
{
|
||||||
|
ContestAndStageId.Add(Contest.Id);
|
||||||
|
ContestAndStageId.Add(Stage.Id);
|
||||||
|
return ContestAndStageId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ContestAndStageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
FString UDTFluxModelHelper::GetCurrentStageName(UDTFluxDataStorage* DataStorage)
|
||||||
|
{
|
||||||
|
FString Name;
|
||||||
|
FDateTime Now = FDateTime::Now();
|
||||||
|
for(const auto& Contest : DataStorage->Contests)
|
||||||
|
{
|
||||||
|
for(const auto& Stage : Contest.Stages)
|
||||||
|
{
|
||||||
|
// Stage has begun
|
||||||
|
if(Stage.StartTime <= Now)
|
||||||
|
{
|
||||||
|
Name = FString::Printf(TEXT("Contest %s Stage %s"), *Contest.Name, *Stage.Name);
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
|||||||
@ -120,5 +120,15 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Model|Helpers")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Model|Helpers")
|
||||||
static EDTFluxStageStatusType GetStatusType(const int ContestID, const int StageID, UDTFluxDataStorage* DataStorage);
|
static EDTFluxStageStatusType GetStatusType(const int ContestID, const int StageID, UDTFluxDataStorage* DataStorage);
|
||||||
|
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Model|Helpers")
|
||||||
|
static int GetCurrentContest(UDTFluxDataStorage* DataStorage);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Model|Helpers")
|
||||||
|
static TArray<int> GetCurrentStage(UDTFluxDataStorage* DataStorage);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Model|Helpers")
|
||||||
|
static FString GetCurrentStageName(UDTFluxDataStorage* DataStorage);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user