diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-28 23:24:08 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-28 23:24:08 +0100 |
| commit | 33452f55afcad603f72e054d56ad7848a3d09503 (patch) | |
| tree | fcef1b0e4a88284ff3fc652fbaecdb087413a17f /src/server/games | |
| parent | v1.1.0: highlight winning symbols on the slots board (diff) | |
| download | zagan-bet-33452f55afcad603f72e054d56ad7848a3d09503.tar.gz zagan-bet-33452f55afcad603f72e054d56ad7848a3d09503.zip | |
v1.2.0: show the symbol paytable on the slots board
Diffstat (limited to 'src/server/games')
| -rw-r--r-- | src/server/games/slots.rs | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/server/games/slots.rs b/src/server/games/slots.rs index 1d71c9d..e9f58b1 100644 --- a/src/server/games/slots.rs +++ b/src/server/games/slots.rs | |||
| @@ -1,19 +1,9 @@ | |||
| 1 | use super::traits::{Game, GameError, GamePhase, GameResult, GameState}; | 1 | use super::traits::{Game, GameError, GamePhase, GameResult, GameState}; |
| 2 | use crate::slots::PAYTABLE; | ||
| 2 | use rand::Rng; | 3 | use rand::Rng; |
| 3 | use std::collections::HashMap; | 4 | use std::collections::HashMap; |
| 4 | 5 | ||
| 5 | pub const REELS: usize = 5; | 6 | pub use crate::slots::{PAYLINES, REELS, ROWS, SYMBOLS}; |
| 6 | pub const ROWS: usize = 3; | ||
| 7 | pub const SYMBOLS: [char; 6] = ['C', 'L', 'O', 'G', 'D', 'S']; | ||
| 8 | |||
| 9 | /// Five paylines, each entry is the row used on reel 0..4. | ||
| 10 | pub const PAYLINES: [[usize; REELS]; 5] = [ | ||
| 11 | [0, 0, 0, 0, 0], // line 1: top | ||
| 12 | [1, 1, 1, 1, 1], // line 2: middle | ||
| 13 | [2, 2, 2, 2, 2], // line 3: bottom | ||
| 14 | [0, 1, 2, 1, 0], // line 4: V | ||
| 15 | [2, 1, 0, 1, 2], // line 5: inverted V | ||
| 16 | ]; | ||
| 17 | 7 | ||
| 18 | #[derive(Clone, Copy)] | 8 | #[derive(Clone, Copy)] |
| 19 | struct Payout { | 9 | struct Payout { |
| @@ -37,15 +27,12 @@ pub struct SlotsGame { | |||
| 37 | 27 | ||
| 38 | impl SlotsGame { | 28 | impl SlotsGame { |
| 39 | pub fn new() -> Self { | 29 | pub fn new() -> Self { |
| 40 | let mut payouts = HashMap::new(); | 30 | let payouts = PAYTABLE |
| 41 | 31 | .iter() | |
| 42 | // RTP = 425/432 = 0.9838 (1.62% house edge) with five paylines. | 32 | .map(|&(symbol, three, four, five)| { |
| 43 | payouts.insert('C', Payout { three: 2, four: 5, five: 15 }); | 33 | (symbol, Payout { three, four, five }) |
| 44 | payouts.insert('L', Payout { three: 3, four: 7, five: 20 }); | 34 | }) |
| 45 | payouts.insert('O', Payout { three: 3, four: 8, five: 25 }); | 35 | .collect(); |
| 46 | payouts.insert('G', Payout { three: 4, four: 12, five: 40 }); | ||
| 47 | payouts.insert('D', Payout { three: 6, four: 18, five: 70 }); | ||
| 48 | payouts.insert('S', Payout { three: 9, four: 30, five: 150 }); | ||
| 49 | 36 | ||
| 50 | Self { | 37 | Self { |
| 51 | payouts, | 38 | payouts, |
