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
11
12
13
14
| void onStreaksList(const Hiro::StreaksList& streaksList)
{
for (auto it = streaksList.streaks.name.begin(); it != streaksList.streaks.name.end(); it++)
{
std::cout << "Found streak: " << it->second.name << '\n';
}
}
void onError(const Nakama::NError& error)
{
std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}
hiroClient->streaksList(session, onStreaksList, onError);
|
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
14
15
16
17
| void onStreaksClaim(const Hiro::StreaksList& streaksList)
{
for (auto it = streaksList.streaks.name.begin(); it != streaksList.streaks.name.end(); it++)
{
std::cout << "Found streak: " << it->second.name << '\n';
}
}
void onError(const Nakama::NError& error)
{
std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}
Hiro::StreaksClaimRequest request;
request.ids.push_back("daily_login");
hiroClient->streaksClaim(session, request, onStreaksClaim, onError);
|
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
14
15
16
17
| void onStreaksReset(const Hiro::StreaksList& streaksList)
{
for (auto it = streaksList.streaks.name.begin(); it != streaksList.streaks.name.end(); it++)
{
std::cout << "Found streak: " << it->second.name << '\n';
}
}
void onError(const Nakama::NError& error)
{
std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}
Hiro::StreaksResetRequest request;
request.ids.push_back("daily_login");
hiroClient->streaksReset(session, request, onStreaksReset, onError);
|
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
14
15
16
17
| void onStreaksUpdate(const Hiro::StreaksList& streaksList)
{
for (auto it = streaksList.streaks.name.begin(); it != streaksList.streaks.name.end(); it++)
{
std::cout << "Found streak: " << it->second.name << '\n';
}
}
void onError(const Nakama::NError& error)
{
std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}
Hiro::StreaksUpdateRequest request;
request.ids.insert(std::make_pair<std::string, std::string>("daily_login", "1"));
hiroClient->streaksUpdate(session, request, onStreaksUpdate, onError);
|