Skip to content

feat(blackjack): make the blackjack game playable end-to-end#57

Merged
netqo merged 1 commit into
devfrom
feat/blackjack-game
Jun 24, 2026
Merged

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

Conversation

@netqo

@netqo netqo commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Wires classic blackjack (CU-06) end-to-end - the fifth and final game, completing the games card. Deal, then Hit / Stand / Double against a dealer that draws to 17, with the opening cards and the dealer's draws animated one at a time.

Rationale

Same round pattern as the other games, with the most hand logic:

  • BlackjackMath is a pure, unit-tested scorer over the engine's card indices (soft-ace totals, bust, natural blackjack, dealer-hits rule).
  • GameRepository.startBlackjack validates the stake (no debit) and draws the shuffled deck on the C++/JNI engine (committed via the hash). settleBlackjack applies the net in one write and records the round with the player/dealer totals - settling net at the end is what makes Double a single doubled settle rather than a second debit.
  • BlackjackViewModel owns the hands and deals card by card with a delay (player/dealer alternating, hole card hidden); the dealer reveals and draws with delays too. Hit / Stand / Double; Split is intentionally out of scope.
  • RoundDetailViewModel branches by game to show "Your Hand" vs "Dealer" with the real seeds.
  • Phases (Idle / Dealing / PlayerTurn / DealerTurn / Result) keep the action grid in place (disabled while dealing) so the layout stays stable.

Verification

  • ./gradlew testDebugUnitTest detekt ktlintCheck assembleDebug compileDebugAndroidTestKotlin green locally (JDK 17).
  • New tests: BlackjackMathTest, BlackjackViewModelTest (stand win, hit bust, natural blackjack 3:2, invalid bet), startBlackjack/settleBlackjack cases in GameRepositoryImplTest.
  • Installed the debug APK on a physical device: dealt hands (cards animate in), hit / stood / doubled, busted, hit naturals; the dealer reveals and draws to 17; balance settles net; rounds show in History and Round Detail (hands + real seeds) and in the Profile P&L.

Test plan

  • Deal lays the opening cards out one at a time; the dealer hole card is hidden.
  • Hit draws; busting over 21 loses.
  • Stand plays the dealer (draws to 17) and compares.
  • Double doubles the stake, draws one card and stands.
  • Natural blackjack pays 3:2; pushes return the stake.
  • The round lands in History / Round Detail (hands + real seeds) and the Profile P&L.

Related issues

Refs the games-card work for the final entrega (Blackjack is the 5th of 5 games; the games card is now complete).

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 classic blackjack through the native provably-fair engine,
completing the games card. BlackjackViewModel -> startBlackjack draws the
shuffled 52-card deck on the C++/JNI engine (committed via the hash); the
opening cards are dealt one at a time with a delay (player/dealer
alternating, the dealer hole card face down). Hit / Stand / Double run on
BlackjackMath (soft-ace totals, dealer stands on 17, natural blackjack
pays 3:2), and the dealer reveals and draws card by card.

The bet settles net at the end (WalletRepository.applyRoundResult, so
Double doubles cleanly) and the round is recorded in game_round with the
player/dealer totals; the round detail branches by game to show the
hands and the real seeds. Split is intentionally out of scope.

Covered by BlackjackMathTest, BlackjackViewModelTest and the
startBlackjack/settleBlackjack cases in GameRepositoryImplTest.
@netqo netqo merged commit 9445dab into dev Jun 24, 2026
3 checks passed
@netqo netqo deleted the feat/blackjack-game branch June 24, 2026 05:30
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