KAZIK/docs/native-durak.md
Artvasil09 3ad5bf4c9d Develop assembly-only casino scenes and native games
Add native Durak, poker, blackjack, roulette, Buckshot and billiards scenes with animation assets and regression tests. Improve arrival, city, hall, profiles, shops, audio and exit handling; remove the portable C game core and refresh shipping executables.
2026-10-08 22:39:19 +03:00

68 lines
3.7 KiB
Markdown

# Native Durak
Durak opens directly from its hall table in the existing MASM graphical
window (mode 19). There is no console fallback, child game process or new
runtime language. Existing table/dealer/card/hand bitmap assets are reused.
## Rules
Two players, a shuffled 36-card deck (6 through ace), six-card initial hands.
The lowest initial trump attacks first; if neither player has a trump, the
first attacker is random. The face-up trump stays at the bottom of the talon
and is eventually drawn, not removed from play.
The attacker can add ranks present on attack or defense cards. A bout is
limited to six attacks or the defender's hand size at the start of that bout,
whichever is smaller. The defender beats cards in their attack order with a
higher card of the same suit or a trump over a non-trump. Taking collects
both attack and defense cards; the attacker can still add legal cards before
ending that bout. Successfully defended cards go to the discard pile.
The original attacker draws first after a bout. A successful defender then
attacks; a defender who takes is skipped. Transfer mode additionally allows
passing an attack by adding a matching rank before any card has been beaten,
provided the new defender can face the whole attack. Transfer can bounce back.
The optional six-of-trumps exchange and trump-showing travel-pass variants
are not enabled.
Rules references: [Pagat: Podkidnoy Durak](https://www.pagat.com/beating/podkidnoy_durak.html)
and [Pagat: Perevodnoy Durak](https://www.pagat.com/beating/perevodnoy_durak.html).
## Input And Presentation
- Ready/result: choose the variant with its button or T; Up/Down or +/-
changes the next stake; Space/Enter or Play deals.
- Left/Right selects a card. Numbers 1..8 select within the displayed page.
Page Up/Down or the side arrows reach larger hands, including all 36 cards.
Clicking a card selects it; the action buttons perform the actual move.
- Enter/Space plays the selected attack/defense, B takes, T transfers,
D ends the attack (only after defense or a declared take).
- Escape or the hall button leaves immediately when idle/settled. During
a paid game it opens a frozen exit confirmation. N/Escape cancels, Y
forfeits the stake and returns to the same hall position.
Cards fly between the hand and table with smoothstep interpolation. Dealer
actions are delayed and nonblocking, and the initial deal is animated. A
card is reserved while in flight, so it cannot exist in two places or vanish.
All action controls remain fixed-size, and player hands use eight-card pages.
The AI uses only its own cards, public table/trump and opponent card count.
It selects the cheapest legal move, preserving trumps when possible; it is
not an optimal solver. A pathological 300-bout take cycle ends in a refunded
push. There is no timed penalty on a human deciding their move.
## Money And Verification
The stake is saved when deducted. Win returns twice the stake, loss returns
nothing, and a draw refunds it. Settlement is idempotent; leaving a paid
game is a loss, not a refund. This uses the native profile, not a replacement
for the legacy console account system.
`tools/tests/durak_test.inc` runs the actual ASM handlers in the existing
headless regression executable, with save writing disabled. It covers both
variants, completed games, the complete beat matrix, card conservation
including talon/discard/in-flight cards, transfer restrictions, fixed bout
limits, taking/refill/trump order, all-card paging, payouts and exit freezes.
Framebuffers are written to `build/actions/durak-*.bmp` for visual inspection.
The shared face-up renderer also has a 52-card fill check: a face-up card
must not index the card-back palette with a volatile register value.