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.
37 lines
1.1 KiB
GDScript
37 lines
1.1 KiB
GDScript
extends RefCounted
|
|
|
|
|
|
static func key_for_screen(screen_name: String, payload: Variant = null) -> String:
|
|
var key := "home"
|
|
if screen_name == "dashboard":
|
|
key = "home"
|
|
elif screen_name == "selection":
|
|
key = "question_bank" if str(payload) == "question_bank" else "home"
|
|
elif screen_name in ["map", "setup", "review"]:
|
|
key = "study_plan" if screen_name == "map" else "question_bank"
|
|
elif screen_name == "player":
|
|
key = "dynamic_questions" if BlockSessionService.session_kind == "dynamic" else "question_bank"
|
|
elif screen_name == "dynamic_questions":
|
|
key = "dynamic_questions"
|
|
elif screen_name.begins_with("simulation_"):
|
|
key = "exams"
|
|
elif screen_name.begins_with("ccs_"):
|
|
key = "ccs"
|
|
elif screen_name.begins_with("flashcards_"):
|
|
key = "flashcards"
|
|
elif screen_name == "profile":
|
|
key = "performance"
|
|
elif screen_name == "settings":
|
|
key = "settings"
|
|
elif screen_name == "notes":
|
|
key = "notes"
|
|
elif screen_name == "bookmarks":
|
|
key = "bookmarks"
|
|
elif screen_name == "donations":
|
|
key = "donations"
|
|
elif screen_name == "rz_store":
|
|
key = "rz_store"
|
|
elif screen_name == "slot_machine":
|
|
key = "rz_store"
|
|
return key
|