GS2-Idle

Abandonment Reward Function

Implement a system that grants rewards based on the length of time a game has not been played.

Categories

Multiple abandonment rewards can be provided. Players can have one waiting time per category.

Abandonment time

The category can have an initial value of how many minutes of abandonment time is rewarded and a maximum value of abandonment time. The maximum abandonment time can be increased by each player.

Abandonment Reward

The Abandonment Reward category defines a list of items that can be obtained after a certain amount of time of abandonment. Multiple rewards to be granted can be set up to a maximum of 10 items, such as “experience + items”.

In addition, multiple lists of rewards can be set up so that there can be variations in the content of rewards within the waiting time.

For example, “Experience +10” and “Enhancement Material Lv.1 x 1” can be obtained for every 10 minutes of waiting. However, at every 60-minute timing, instead of the above rewards, “Experience +20” and “Enhancement Material Lv. 2 x 1” can be obtained. Consider the above example.

In this case, the following table is set up for the abandoned rewards.

-reward1reward2
1Experience +10Enhancement Material Lv.1 x 1
2Experience +10Enhancement Material Lv.1 x 1
3Experience +10Enhancement Material Lv.1 x 1
4Experience +10Enhancement Material Lv.1 x 1
5Experience +10Enhancement Material Lv.1 x 1
6Experience +20Enhancement Material Lv.2 x 1

The content of the reward item can now be changed according to the elapsed time. The content of the reward loops, so after 2 hours, you will have the items “1,2,3,4,5,6,1,2,3,4,5,6”.

Random drawings for abandonment rewards

Sometimes we want to have more randomness in the rewards. In such cases, you can set up GS2-Lottery’s lottery process for the rewards.

In the conventional GS2-Lottery, the result is not determined until the lottery is drawn, but when GS2-Idle is used, a random number seed is generated at the start of the waiting period, and the seed is used for the calculation of the reward. In the case of GS2-Idle, a random number seed is generated at the start of the waiting period, and the random number seed is used to draw a lotteries when calculating the reward. (Changing the GS2-Lottery prize table will destroy this assumption.)

Scheduling of standby time

Each category can be associated with an event in GS2-Schedule so that abandoned rewards can be implemented in conjunction with the event.

Suppose the event duration is 2023-01-01 00:00 ~ 2023-02-01 00:00, and the wait begins at 2023-01-31 23:00. In this case, the count of the abandonment time stops when 2023-02-01 00:00 is reached.

Therefore, the content of the reward will be the same whether you receive it on 2023-02-01 01:00 or on 2023-02-01 09:00.

If the event has a repeat setting, the abandonment time is reset when the repeat count changes. For example, if an event repeats every Monday 00:00 ~ Tuesday 00:00, the waiting time will be reset even if you did not receive the previous week’s reward at the moment it reaches 00:00 the following Monday.

Apart from the waiting time schedule, you can set the period during which rewards can be received.

Example implementation

Start of Waiting Time

Waiting is started when the waiting time information is retrieved for the first time.

    var item = await gs2.Idle.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Status(
        category: "category-0001"
    ).ModelAsync();
    const auto Future = Gs2->Idle->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Status(
        "category-0001" // categoryName
    )->ModelAsync();
    Future->StartSynchronousTask();
    if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;

Get Waiting List.

    var items = await gs2.Idle.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).StatusesAsync(
    ).ToListAsync();
    const auto It = Gs2->Idle->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Statuses(
    );
    for (auto Item : *It)
    {

    }

Check the reward.

    var items = await gs2.Idle.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Status(
        category: "category-0001"
    ).PredictionAsync();
    const auto It = Gs2->Idle->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Status(
        "category-0001" // categoryName
    )->PredictionAsync();
    for (auto Item : *It)
    {

    }

Receiving Rewards

When a reward is received, the waiting time is reset. Also, if there is too much time left in the waiting time before the reward is earned, it will be reset to 0.

    await gs2.Idle.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Status(
        category: "category-0001"
    ).ReceiveAsync();
    const auto Future = Gs2->Idle->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Status(
        "category-0001" // categoryName
    )->ReceiveAsync();
    Future->StartSynchronousTask();
    if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;

Advanced Reference.