Streaks
#
Read more about the Streak system in Hiro here.
Listing streaks
#
You can list the current streaks for the user:
1
2
3
4
5
6
7
8
9
10
| FHiroOnStreaksList OnStreaksList;
OnStreaksList.AddDynamic(this, &AMyActor::OnStreaksList)
FOnError OnError;
HiroClient->StreaksList(Session, OnStreaksList, OnError)
void AMyActor::OnStreaksList(const FHiroStreaksList& StreaksList)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *StreaksList.ToJson());
}
|
Claiming Streaks Rewards
#
Players can claim streak rewards using the StreaksClaim
method, passing the streak IDs.
1
2
3
4
5
6
7
8
9
10
11
12
13
| FHiroStreaksClaimRequest Request;
Request.Ids.Add(TEXT("daily_login"));
FHiroOnStreaksClaim OnStreaksClaim;
OnStreaksClaim.AddDynamic(this, &AMyActor::OnStreaksClaim)
FOnError OnError;
HiroClient->StreaksClaim(Session, Request, OnStreaksClaim, OnError)
void AMyActor::OnStreaksClaim(const FHiroStreaksList& StreaksList)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *StreaksList.ToJson());
}
|
Resetting Streaks
#
To reset specific streaks for a player, use the StreaksReset
method:
1
2
3
4
5
6
7
8
9
10
11
12
13
| FHiroStreaksResetRequest Request;
Request.Ids.Add(TEXT("daily_login"));
FHiroOnStreaksReset OnStreaksReset;
OnStreaksReset.AddDynamic(this, &AMyActor::OnStreaksReset)
FOnError OnError;
HiroClient->StreaksReset(Session, Request, OnStreaksReset, OnError)
void AMyActor::OnStreaksReset(const FHiroStreaksList& StreaksList)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *StreaksList.ToJson());
}
|
Updating Streaks
#
You can manually update streaks for a player by passing a dictionary of streak names and new values:
1
2
3
4
5
6
7
8
9
10
11
12
13
| FHiroStreaksUpdateRequest Request;
Request.Ids.Add(TEXT("daily_login"), 1);
FHiroOnStreaksUpdate OnStreaksUpdate;
OnStreaksUpdate.AddDynamic(this, &AMyActor::OnStreaksUpdate)
FOnError OnError;
HiroClient->StreaksUpdate(Session, Request, OnStreaksUpdate, OnError)
void AMyActor::OnStreaksUpdate(const FHiroStreaksList& StreaksList)
{
UE_LOG(LogTemp, Log, TEXT("%s"), *StreaksList.ToJson());
}
|