From 33452f55afcad603f72e054d56ad7848a3d09503 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 28 Oct 2026 23:24:08 +0100 Subject: v1.2.0: show the symbol paytable on the slots board --- src/server/games/slots.rs | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'src/server/games') 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 @@ use super::traits::{Game, GameError, GamePhase, GameResult, GameState}; +use crate::slots::PAYTABLE; use rand::Rng; use std::collections::HashMap; -pub const REELS: usize = 5; -pub const ROWS: usize = 3; -pub const SYMBOLS: [char; 6] = ['C', 'L', 'O', 'G', 'D', 'S']; - -/// Five paylines, each entry is the row used on reel 0..4. -pub const PAYLINES: [[usize; REELS]; 5] = [ - [0, 0, 0, 0, 0], // line 1: top - [1, 1, 1, 1, 1], // line 2: middle - [2, 2, 2, 2, 2], // line 3: bottom - [0, 1, 2, 1, 0], // line 4: V - [2, 1, 0, 1, 2], // line 5: inverted V -]; +pub use crate::slots::{PAYLINES, REELS, ROWS, SYMBOLS}; #[derive(Clone, Copy)] struct Payout { @@ -37,15 +27,12 @@ pub struct SlotsGame { impl SlotsGame { pub fn new() -> Self { - let mut payouts = HashMap::new(); - - // RTP = 425/432 = 0.9838 (1.62% house edge) with five paylines. - payouts.insert('C', Payout { three: 2, four: 5, five: 15 }); - payouts.insert('L', Payout { three: 3, four: 7, five: 20 }); - payouts.insert('O', Payout { three: 3, four: 8, five: 25 }); - payouts.insert('G', Payout { three: 4, four: 12, five: 40 }); - payouts.insert('D', Payout { three: 6, four: 18, five: 70 }); - payouts.insert('S', Payout { three: 9, four: 30, five: 150 }); + let payouts = PAYTABLE + .iter() + .map(|&(symbol, three, four, five)| { + (symbol, Payout { three, four, five }) + }) + .collect(); Self { payouts, -- cgit v1.2.3