[PR #137] [MERGED] SMP 0.23.0: the casino (roulette, slots, crash, blackjack) #139

Closed
opened 2026-11-03 04:03:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon-mods/pull/137
Author: @ludovic111
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat/smp-casino


📝 Commits (1)

  • 6932050 SMP 0.23.0: the casino (roulette, slots, crash, blackjack), paid from its own pot

📊 Changes

14 files changed (+4704 additions, -10 deletions)

View changed files

📝 native/smp/Cargo.lock (+1 -1)
📝 native/smp/Cargo.toml (+1 -1)
📝 native/smp/README.md (+32 -1)
➕ native/smp/mixins/smp/casino_glue.rs (+333 -0)
📝 native/smp/mixins/smp/glue.rs (+65 -5)
📝 native/smp/mixins/smp/horizon-mixin.toml (+37 -1)
➕ native/smp/mixins/smp/smp_casino.rs (+1898 -0)
➕ native/smp/mixins/smp/smp_casino_blackjack.rs (+657 -0)
➕ native/smp/mixins/smp/smp_casino_crash.rs (+543 -0)
➕ native/smp/mixins/smp/smp_casino_roulette.rs (+526 -0)
➕ native/smp/mixins/smp/smp_casino_slots.rs (+298 -0)
📝 native/smp/proof.py (+10 -1)
➕ native/smp/proof_casino.py (+293 -0)
📝 native/smp/src/lib.rs (+10 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

SMP 0.23.0: a casino for the official server, played by stock 26.3 clients through chest menus.

What players get

  • /casino: a lobby menu (the four games, the pot, today's biggest wins, what you may still lose today). /casino help shows every game's odds and house edge, /casino top and /casino stats.
  • European roulette: one zero; red/black, odd/even, 1-18/19-36 (1:1), dozens and columns (2:1), single numbers (35:1). House edge 2.70%. The wheel turns and slows down on the drawn pocket.
  • Slots: 3 reels × 32 stops of item symbols, one payline, published paytable (3 Nether Stars 500x … 3 Berries 6x, 2 Berries 2x). Exact RTP 94.2% (the test enumerates all 32,768 lines), one pull in 4.5 pays.
  • Crash: one shared round; bet in the 10 s before take-off, cash out (or set an automatic cash-out) before it crashes. P(crash ≥ x) = 96%/x, capped at 100x → 96% paid back whatever the strategy. Multiplier in the menu, the action bar and a boss bar.
  • Blackjack: 6 decks shuffled each hand, dealer stands on all 17s and peeks, blackjack 3:2, double on two cards, no split (~1% edge with basic strategy, checked by a simulation test).
  • Results by title / action bar / sounds; a jackpot (≥ 50x) or a big win (≥ 5,000 profit) gets fireworks and a line for everyone.

Money

  • Bets are hold-ed, then settled exactly once with settle_pool(kind, uuid, stake, payout, "casino") (#127): wins come from the casino's own pot, a win larger than the pot is paid up to what it holds, coins are never minted.
  • Hourly, the pot above casino.float (20,000) goes to the Treasury (casino_profit); below it, the Treasury tops it up with what it holds (casino_float).
  • Limits (config.json casino): bets 10–1,000, daily_loss_cap 10,000 a player a day (UTC, all games), cooldown_ms 2,000. Draws: ChaCha20 keyed from the system (RFC 8439 test vector), rejection sampling, made before the animation starts.
  • Closing the menu or leaving never loses a round: a spin or a pull ends and is paid, a blackjack hand stands, a crash bet is cashed out when its player leaves in flight (given back before take-off). Double clicks start one round.
  • casino.json keeps the day's ledger (per-player wagered/paid for the loss cap, the day's wins, per-game totals). The casino is off unless gambling.enabled.

Cost

  • Idle: the casino's step runs once a second (the hourly sweep, players who left), nothing per tick.
  • Playing: menus are repainted only while a round moves, at most 5 pictures a second per open menu. twenty_players_playing_cost_per_tick (ignored test, release): 20 players playing at once without pause (8 slots, 6 roulette, 6 crash) cost 20.6 µs a tick on average, 0.69 ms at worst, 86 pictures a second for the 20 menus.
  • Crash boss bars: one bar per player in or watching the round, because Horizon's selectors don't see server players' tags (tags_of(Target::Guest) is empty), so @a[tag=…] found nobody.

Proof

SMP_PROOF=casino python3 native/tools/native.py proof --resources … smp (proof_casino.py): a dedicated server with the mod and two real clients (horizon-ctl, under Xvfb on playhorizon). Lobby → roulette (13–14 distinct pictures in a 3.6–3.9 s spin, result in the action bar), a spin with the menu closed mid-spin, slots with a double click (one pull), a pull closed mid-reel, blackjack, max bet, and crash with both players (Steve disconnects mid-flight, Alex cashes out). Checked after the stop: 7 rounds each settled exactly once in audit.log, nothing left held, balances + pools = the Treasury's starting 50,000, casino.json totals. Passed on the last head's code before the rebase onto 0.22.0; the rebase only merged glue.rs/README/version with #126/#128–#133.

Not in this PR

  • Jackpots to the Discord bridge: horizon-server's bridge only relays chat/join/leave/death/kick, and no native API lets a mod record an event; needs a Horizon change first (follow-up).
  • No physical casino (block displays).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon-mods/pull/137 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/smp-casino` --- ### 📝 Commits (1) - [`6932050`](https://github.com/horizon-rust/horizon-mods/commit/693205032b91f54961042464c1b8ba5998039c96) SMP 0.23.0: the casino (roulette, slots, crash, blackjack), paid from its own pot ### 📊 Changes **14 files changed** (+4704 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `native/smp/Cargo.lock` (+1 -1) 📝 `native/smp/Cargo.toml` (+1 -1) 📝 `native/smp/README.md` (+32 -1) ➕ `native/smp/mixins/smp/casino_glue.rs` (+333 -0) 📝 `native/smp/mixins/smp/glue.rs` (+65 -5) 📝 `native/smp/mixins/smp/horizon-mixin.toml` (+37 -1) ➕ `native/smp/mixins/smp/smp_casino.rs` (+1898 -0) ➕ `native/smp/mixins/smp/smp_casino_blackjack.rs` (+657 -0) ➕ `native/smp/mixins/smp/smp_casino_crash.rs` (+543 -0) ➕ `native/smp/mixins/smp/smp_casino_roulette.rs` (+526 -0) ➕ `native/smp/mixins/smp/smp_casino_slots.rs` (+298 -0) 📝 `native/smp/proof.py` (+10 -1) ➕ `native/smp/proof_casino.py` (+293 -0) 📝 `native/smp/src/lib.rs` (+10 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. SMP 0.23.0: a casino for the official server, played by stock 26.3 clients through chest menus. ## What players get - `/casino`: a lobby menu (the four games, the pot, today's biggest wins, what you may still lose today). `/casino help` shows every game's odds and house edge, `/casino top` and `/casino stats`. - **European roulette**: one zero; red/black, odd/even, 1-18/19-36 (1:1), dozens and columns (2:1), single numbers (35:1). House edge 2.70%. The wheel turns and slows down on the drawn pocket. - **Slots**: 3 reels × 32 stops of item symbols, one payline, published paytable (3 Nether Stars 500x … 3 Berries 6x, 2 Berries 2x). Exact RTP 94.2% (the test enumerates all 32,768 lines), one pull in 4.5 pays. - **Crash**: one shared round; bet in the 10 s before take-off, cash out (or set an automatic cash-out) before it crashes. P(crash ≥ x) = 96%/x, capped at 100x → 96% paid back whatever the strategy. Multiplier in the menu, the action bar and a boss bar. - **Blackjack**: 6 decks shuffled each hand, dealer stands on all 17s and peeks, blackjack 3:2, double on two cards, no split (~1% edge with basic strategy, checked by a simulation test). - Results by title / action bar / sounds; a jackpot (≥ 50x) or a big win (≥ 5,000 profit) gets fireworks and a line for everyone. ## Money - Bets are `hold`-ed, then settled exactly once with `settle_pool(kind, uuid, stake, payout, "casino")` (#127): wins come from the casino's own pot, a win larger than the pot is paid up to what it holds, coins are never minted. - Hourly, the pot above `casino.float` (20,000) goes to the Treasury (`casino_profit`); below it, the Treasury tops it up with what it holds (`casino_float`). - Limits (config.json `casino`): bets 10–1,000, `daily_loss_cap` 10,000 a player a day (UTC, all games), `cooldown_ms` 2,000. Draws: ChaCha20 keyed from the system (RFC 8439 test vector), rejection sampling, made before the animation starts. - Closing the menu or leaving never loses a round: a spin or a pull ends and is paid, a blackjack hand stands, a crash bet is cashed out when its player leaves in flight (given back before take-off). Double clicks start one round. - `casino.json` keeps the day's ledger (per-player wagered/paid for the loss cap, the day's wins, per-game totals). The casino is off unless `gambling.enabled`. ## Cost - Idle: the casino's step runs once a second (the hourly sweep, players who left), nothing per tick. - Playing: menus are repainted only while a round moves, at most 5 pictures a second per open menu. `twenty_players_playing_cost_per_tick` (ignored test, release): 20 players playing at once without pause (8 slots, 6 roulette, 6 crash) cost **20.6 µs a tick on average, 0.69 ms at worst**, 86 pictures a second for the 20 menus. - Crash boss bars: one bar per player in or watching the round, because Horizon's selectors don't see server players' tags (`tags_of(Target::Guest)` is empty), so `@a[tag=…]` found nobody. ## Proof `SMP_PROOF=casino python3 native/tools/native.py proof --resources … smp` (`proof_casino.py`): a dedicated server with the mod and two real clients (horizon-ctl, under Xvfb on playhorizon). Lobby → roulette (13–14 distinct pictures in a 3.6–3.9 s spin, result in the action bar), a spin with the menu closed mid-spin, slots with a double click (one pull), a pull closed mid-reel, blackjack, max bet, and crash with both players (Steve disconnects mid-flight, Alex cashes out). Checked after the stop: 7 rounds each settled exactly once in audit.log, nothing left held, balances + pools = the Treasury's starting 50,000, casino.json totals. Passed on the last head's code before the rebase onto 0.22.0; the rebase only merged glue.rs/README/version with #126/#128–#133. ## Not in this PR - Jackpots to the Discord bridge: horizon-server's bridge only relays chat/join/leave/death/kick, and no native API lets a mod record an event; needs a Horizon change first (follow-up). - No physical casino (block displays). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:03:33 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon-mods#139
No description provided.