Stamina Shop

Overview

A shop that sells stamina for coins. Collect free coins under Get coins, use some stamina under Your stamina, then buy one of the three refill tiers on The shelf. Each purchase is a GS2-Exchange exchange that withdraws coins from GS2-Money2 and refills GS2-Stamina in one transaction.

How to try it

  1. Press Deposit under Get coins; Free balance under Your coins goes up by 100.
  2. Press Spend under Your stamina to use 10 stamina (maximum 100, starting at 50). While the meter is not full, Next recovery shows the time until the next natural recovery (5 every minute).
  3. The shelf lists three products: +5 stamina for 30 coins, +15 stamina for 70 coins and +40 stamina for 100 coins.
  4. Press Buy on any product; its price comes out of Free balance and the Stamina gauge goes up by its recovery amount.
  5. Buy is refused when you do not have enough coins; press Deposit under Get coins to top up.

The stamina model allows overflow, so buying near a full meter can take it past 100.

GS2 services used

  • GS2-Exchange: One GS2-Exchange rate per product turns the coin cost and the stamina refill into a single purchase transaction; the free-coin deposit and the stamina spend are exchange rates too.
  • GS2-Stamina: GS2-Stamina holds the stamina meter (maximum 100, recovering 5 every minute) and refills it by the product’s amount on purchase.
  • GS2-Money2: The GS2-Money2 wallet holds the free coins, and each purchase withdraws the product’s price from it.

Use it in GS2 Studio

In GS2 Studio’s Simple mode, open Add features and press Add on Stamina Shop to bring this feature into your own project. To point at the package directly, choose Add from GitHub and enter the package below.

https://github.com/gs2io/gs2-studio-package/tree/main/micro-shop-energy/packages/micro-shop-energy
  • Owner: gs2io
  • Repository: gs2-studio-package
  • Subdirectory: micro-shop-energy/packages/micro-shop-energy

Source code