[go: up one dir, main page]

Tutorials #

Read more about the Tutorials system in Hiro here.

Get all tutorials #

Get the tutorials and current progress step for the player.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
void onTutorialsGet(const Hiro::TutorialList& tutorialList)
{
    for (auto it = tutorialList.tutorials.begin(); it != tutorialList.tutorials.end(); it++)
    {
        std::cout << "Found tutorial: " << it->second.id << ". Progress: " << it->second.current << '/' << it->second.max << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

hiroClient->tutorialsGet(session, onTutorialsGet, onError);

Accept a tutorial #

Accept an offer to step through a tutorial.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
void onTutorialsAccept(const Hiro::Tutorial& tutorial)
{
    std::cout << "Successfully accepted tutorial: " << tutorial.id << '\n';
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::TutorialAcceptRequest request;
request.id = "tutorial_1";

hiroClient->tutorialsAccept(session, request, onTutorialsAccept, onError);

Decline a tutorial #

Decline an offer to start a tutorial.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
void onTutorialsDecline(const Hiro::Tutorial& tutorial)
{
    std::cout << "Successfully declined tutorial: " << tutorial.id << '\n';
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::TutorialDeclineRequest request;
request.id = "tutorial_1";

hiroClient->tutorialsDecline(session, request, onTutorialsDecline, onError);

Abandon a tutorial #

Abandon progress on a tutorial.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
void onTutorialsAbandon(const Hiro::Tutorial& tutorial)
{
    std::cout << "Successfully abandoned tutorial: " << tutorial.id << '\n';
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::TutorialAbandonRequest request;
request.id = "tutorial_1";

hiroClient->tutorialsAbandon(session, request, onTutorialsAbandon, onError);

Update progress of a tutorial #

Update the current progress step in the tutorial by ID.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
void onTutorialsUpdate(const Hiro::TutorialList& tutorialList)
{
    for (auto it = tutorialList.tutorials.begin(); it != tutorialList.tutorials.end(); it++)
    {
        std::cout << "Found tutorial: " << it->second.id << ". Progress: " << it->second.current << '/' << it->second.max << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::TutorialUpdateRequest request;
request.id = "tutorial_1";
request.step = 1;

hiroClient->tutorialsUpdate(session, request, onTutorialsUpdate, onError);