Skip to content

feat(crash): make the crash game playable end-to-end#55

Merged
netqo merged 1 commit into
devfrom
feat/crash-game
Jun 23, 2026
Merged

feat(crash): make the crash game playable end-to-end#55
netqo merged 1 commit into
devfrom
feat/crash-game

Conversation

@netqo

@netqo netqo commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

Wires Crash (CU-07) end-to-end: the third playable game and the first real-time one. Place a bet, watch the multiplier climb along an exponential curve, and cash out before it crashes (or set an auto-cashout target).

Rationale

Same round pattern as Coinflip/Mines, extended for a time-driven round:

  • GameRepository.startCrash validates + debits the stake and draws the crash point on the C++/JNI engine (committed via the hash); settleCrash credits the payout on cash out and records the round. Reuses WalletRepository.applyRoundResult.
  • CrashCurve is a pure, unit-tested exponential curve (e^(t/TAU)), kept out of the engine and ViewModel.
  • CrashViewModel runs a ticker that samples the curve until the crash point, supporting manual cash out and an auto-cashout target. The live multiplier is a dedicated StateFlow<Double>, separate from the slow CrashUiState, so the per-frame ticker only recomposes the chart and the hero readout - the recomposition story the Profiler report will make for Crash.
  • RoundDetailViewModel branches by game and rebuilds the cashout-vs-crash position bar (the crash-shaped detail) from the round's real seeds.
  • Controls swap by phase (setup / live / result) and the finished round shows a compact result panel, so the weighted chart keeps its room and the layout stays stable on a cash out or a crash.

Verification

  • ./gradlew testDebugUnitTest detekt ktlintCheck assembleDebug compileDebugAndroidTestKotlin green locally (JDK 17).
  • New tests: CrashCurveTest, CrashViewModelTest (cash out settles a win; reaching the crash point settles a loss), startCrash/settleCrash cases in GameRepositoryImplTest.
  • Installed the debug APK on a physical device: placed bets (stake debited), watched the multiplier climb smoothly, cashed out (payout credited), let rounds crash (stake lost), exercised the auto-cashout target. Confirmed the round shows in History and Round Detail with the position bar + real seeds, the Profile P&L includes Crash, and the layout stays stable across cash out / crash.

Test plan

  • Place Bet debits the stake and starts the climbing multiplier.
  • Cash Out credits stake x the current multiplier.
  • Reaching the crash point loses the stake.
  • An auto-cashout target cashes out at that multiplier (unless it crashes first).
  • The round lands in History / Round Detail (with the position bar + real seeds) and the Profile P&L.
  • The layout stays stable on cash out and crash; New Bet returns to setup.

Related issues

Refs the games-card work for the final entrega (Crash is the 3rd of 5 games).

Checklist

  • Commit messages follow Conventional Commits (see CONTRIBUTING.md).
  • Branch name follows the naming convention (feat/, fix/, chore/, etc.).
  • The change is scoped: no unrelated edits sneaked into this PR.
  • If user-visible behavior changed, CHANGELOG.md has been updated under [Unreleased].
  • If a new dependency was added, it is justified in the PR description. (No new dependencies.)

Wire Crash through the native provably-fair engine with a real-time
climbing multiplier. CrashViewModel -> GameRepository.startCrash
validates and debits the stake and draws the crash point on the C++/JNI
engine (committed via the hash). A ticker animates the multiplier along
an exponential curve (CrashCurve); manual cash out or an optional
auto-cashout target credits stake x the multiplier
(WalletRepository.applyRoundResult), while reaching the crash point first
loses the stake. The round persists to game_round.

The live multiplier is a dedicated StateFlow, separate from the slow
CrashUiState, so the per-frame ticker only recomposes the chart and the
hero readout (the recomposition story the Profiler report makes for
Crash). The round detail branches by game and rebuilds the
cashout-vs-crash position bar from the real seeds. Controls swap by phase
(setup / live / result) so the layout stays stable on a cash out or a
crash.

Covered by CrashCurveTest, CrashViewModelTest and the startCrash/
settleCrash cases in GameRepositoryImplTest.
@netqo netqo merged commit 1434be7 into dev Jun 23, 2026
3 checks passed
@netqo netqo deleted the feat/crash-game branch June 23, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant