GS2-LoginReward

login bonus feature

Implement a system that allows users to obtain rewards for logging in every day.

Mode

There are two ways to provide login bonus: 《Scheduled Mode》 and 《Streaming Mode》.

Scheduled Mode

This mode is used in conjunction with GS2-Schedule events. Define transaction actions to be distributed as rewards for each schedule. Rewards change every 24 hours from the event start date and time, and each reward can be received once. Any rewards missed during the course of the event will be skipped.

Streaming Mode

Streaming mode distributes the transaction actions to be distributed as rewards set in the stream, starting from the top. If there is a day you did not receive the reward, it will not be skipped and you will get the next reward in the stream.

If you associate a GS2-Schedule event with a Streaming Mode login bonus, you will receive the next reward in the stream every 24 hours from the event start date and time. If not set, you can use the time in 24-hour increments in the UTC time zone to specify when the reward type changes.

Repeat

Streaming mode login bonuses can be set to repeat. If the repeat setting is enabled, when the end of the stream is reached, the next day the reward will resume from the beginning of the stream. This feature can be used to loop the permanent login bonus every 7 days or every 30 days.

Missed Compensation

The Missed Compensation feature is a feature that can be used when you miss an item in scheduled mode or when you are in a situation where you cannot get all the items in the stream even in streaming mode during the event period. By paying a set cost, the missed items can be obtained.

Missed Compensation is only available for login bonuses associated with GS2-Schedule events, and only up to the number of days elapsed from the start date of the event. In other words, future login bonuses cannot be received even if the cost is paid.

Example Implementation.

Receiving login bonuses.

    var result = await gs2.LoginReward.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).Bonus(
    ).ReceiveAsync(
        bonusModelName: "bonus-0001",
        config: null
    );
    const auto Future = Gs2->LoginReward->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->Bonus(
    )->Receive(
        "bonus-0001", // bonusModelName
        nullptr // config
    );
    Future->StartSynchronousTask();
    if (!TestFalse(WHAT, Future->GetTask().IsError())) return false;

Get status of receiving login bonus

    var item = await gs2.LoginReward.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).ReceiveStatus(
        bonusModelName: "bonus-0001"
    ).ModelAsync();
    const auto item = Gs2->LoginReward->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        AccessToken
    )->ReceiveStatus(
        "bonus-0001" // bonusModelName
    ).Model();

Check the contents of the login bonus

    var item = await gs2.LoginReward.Namespace(
        namespaceName: "namespace-0001"
    ).BonusModel(
        bonusModelName: "bonus-0001"
    ).ModelAsync();
    const auto item = Gs2->LoginReward->Namespace(
        "namespace-0001" // namespaceName
    )->BonusModel(
        "bonus-0001" // bonusModelName
    ).Model();

Advanced Reference.