Add an RZ Coin slot machine

Adds a spend-coins-for-a-random-reward mini-game reachable from the
shop. Backend mirrors the store's existing atomic/idempotent purchase
pattern (SpinAsync in CreditStore.cs) with a server-authoritative,
weighted reward roll and a rolling per-user spin-rate guard; odds are
served from GET /api/credits/spin-config so the client never hardcodes
numbers that could drift from the real payout table. The mockup's
"Streak Protector" reward was swapped for a real Exam Simulation Token
since streaks aren't currently a persisted, protectable concept.

Also fixes two latent bugs surfaced while building this:
- credits_service.gd's operation-id builder referenced a nonexistent
  AuthState.user_id (should be .username), throwing on every credit
  action.
- _post() silently no-op'd with no signal when signed out, which
  combined with a GDScript closure gotcha (lambdas capture outer
  locals by value, so reassigning inside one never reached the
  caller) meant a spin attempted while unauthenticated could hang
  forever instead of surfacing an error.
This commit is contained in:
hz
2026-07-30 00:29:49 -05:00
parent 4909cf0b71
commit 1860e6ede6
8 changed files with 816 additions and 3 deletions
+2
View File
@@ -31,4 +31,6 @@ static func key_for_screen(screen_name: String, payload: Variant = null) -> Stri
key = "donations"
elif screen_name == "rz_store":
key = "rz_store"
elif screen_name == "slot_machine":
key = "rz_store"
return key