Pay a double-speed boost correctly when it runs out while the player is away
A ten-minute boost is easy while the game is open. The trouble starts when the player leaves after four minutes and returns an hour later: giving the boost for the whole hour is too generous, giving none is unfair. Here is the exact split, plus the guard against clocks that go backwards.
Why this works
A bonus is a promise of some amount of time, so the time spent away should be used up against it, and only what remains of the promise gets the better rate. Counting remaining seconds, not an end date, keeps the clock from cheating it.
When not to use it
Do not split the time when the boost is paid for with real money and players expect it to run only while they play. Then pause it while they are away, or the purchase feels wasted.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 23 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Pay a double-speed boost correctly when it runs out while the player is away" (read_entry idle-timed-boost-that-runs-out-while-away) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP