feat(crash): make the crash game playable end-to-end#55
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.startCrashvalidates + debits the stake and draws the crash point on the C++/JNI engine (committed via the hash);settleCrashcredits the payout on cash out and records the round. ReusesWalletRepository.applyRoundResult.CrashCurveis a pure, unit-tested exponential curve (e^(t/TAU)), kept out of the engine and ViewModel.CrashViewModelruns a ticker that samples the curve until the crash point, supporting manual cash out and an auto-cashout target. The live multiplier is a dedicatedStateFlow<Double>, separate from the slowCrashUiState, so the per-frame ticker only recomposes the chart and the hero readout - the recomposition story the Profiler report will make for Crash.RoundDetailViewModelbranches by game and rebuilds the cashout-vs-crash position bar (the crash-shaped detail) from the round's real seeds.Verification
./gradlew testDebugUnitTest detekt ktlintCheck assembleDebug compileDebugAndroidTestKotlingreen locally (JDK 17).CrashCurveTest,CrashViewModelTest(cash out settles a win; reaching the crash point settles a loss),startCrash/settleCrashcases inGameRepositoryImplTest.Test plan
Related issues
Refs the games-card work for the final entrega (Crash is the 3rd of 5 games).
Checklist
feat/,fix/,chore/, etc.).[Unreleased].