GS2-Stamina
Stamina is used to limit the number of times a game can be played. GS2-Limit expresses the limit as “3 times a day”, while GS2-Stamina uses stamina that recovers 1 point in 8 hours to realize the limit of 3 times a day.
In the case of stamina, by differentiating the points used, it is possible to achieve specifications such as 3 times per day for action A and 5 times per day for action B. This makes it easier to balance the game by setting guidelines for experience and in-game currency earned per stamina, and eliminates the idea that every action in the game is an efficient action.
We don’t often specify this, though, because developers should strive to get people to log in every day. For players, if the spec allows them to recover 1 point every 8 hours and accumulate up to 15 points, they can log in once every 5 days without having to log in every day and still use up their points without wasting them.
Stamina
Stamina includes “Recovery Cycle”, “Recovery Amount”, and “Maximum Value”.
Overflow
Stamina can be recovered beyond the maximum value. If the maximum is exceeded, there will be no recovery over time. Also, even if the maximum is exceeded, the “true maximum” can be set so that no more is added for UI reasons, etc.
Why do you let it overflow?
This spec may seem strange to developers who have not had the opportunity to play many games that include stamina in the spec.
Generally, stamina is restored through items or in-game purchases. This specification was created to minimize the stress on the player when using the item or purchasing stamina.
Here is a specific example.
The game restores 1 point of stamina every 5 minutes, and your maximum stamina is 50 points. You need 10 stamina points to play the next quest you want to play. However, your current stamina is only 9 points and you have to wait 5 minutes before you can play the next quest. So you decide to buy stamina. Purchasing stamina restores 50 stamina points. However, if you buy stamina now, even if you restore 50 points, 9 points will be wasted. So you wait 5 minutes to play the quest after it restores 1 point, and then you buy stamina to play the next quest after it restores 0 points.
This does not allow players to play the game comfortably. As a result, games were created that introduced a specification that allowed players to recover stamina beyond the maximum.
Let’s take a look at how the user experience changes with the addition of overflow specification.
Currently, your stamina is down to 9 points, and you have to wait 5 minutes before you can play the next quest. So you buy stamina, regain 50 stamina points, and now have 59 stamina points. In this state, stamina will no longer be restored over time, but you immediately start the next quest, bringing your stamina to 49 points.
Example implementation.
Get current stamina value
var item = await gs2.Stamina.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Stamina(
staminaName: "stamina-0001"
).ModelAsync();
const auto Domain = Gs2->Stamina->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Stamina(
"stamina-0001" // staminaName
);
const auto item = Domain.Model();
Consuming Stamina
It is not recommended to use this API to consume stamina.
It is recommended to use GS2-Quest or other services to perform some other process instead of consuming stamina.
var result = await gs2.Stamina.Namespace(
namespaceName: "namespace-0001"
).Me(
gameSession: GameSession
).Stamina(
staminaName: "stamina-0001"
).ConsumeAsync(
consumeValue: 50
);
var item = await result.ModelAsync();
const auto Domain = Gs2->Stamina->Namespace(
"namespace-0001" // namespaceName
)->Me(
AccessToken
)->Stamina(
"stamina-0001" // staminaName
);
const auto Future = Domain->Consume(
50
);
Future->StartSynchronousTask();
if (Future->GetTask().IsError()) return false;