diff options
Diffstat (limited to '')
| -rw-r--r-- | src/server/games/slots.rs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/server/games/slots.rs b/src/server/games/slots.rs index e9f58b1..298cd4c 100644 --- a/src/server/games/slots.rs +++ b/src/server/games/slots.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 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 crate::slots::{SHAPE_MULTIPLIERS, SYMBOL_MULTIPLIERS}; |
| 3 | use rand::Rng; | 3 | use rand::Rng; |
| 4 | use std::collections::HashMap; | 4 | use std::collections::HashMap; |
| 5 | 5 | ||
| @@ -27,10 +27,18 @@ pub struct SlotsGame { | |||
| 27 | 27 | ||
| 28 | impl SlotsGame { | 28 | impl SlotsGame { |
| 29 | pub fn new() -> Self { | 29 | pub fn new() -> Self { |
| 30 | let payouts = PAYTABLE | 30 | // payout = bet * symbol multiplier * shape multiplier |
| 31 | let payouts = SYMBOL_MULTIPLIERS | ||
| 31 | .iter() | 32 | .iter() |
| 32 | .map(|&(symbol, three, four, five)| { | 33 | .map(|&(symbol, symbol_multiplier)| { |
| 33 | (symbol, Payout { three, four, five }) | 34 | ( |
| 35 | symbol, | ||
| 36 | Payout { | ||
| 37 | three: symbol_multiplier * SHAPE_MULTIPLIERS[0].1, | ||
| 38 | four: symbol_multiplier * SHAPE_MULTIPLIERS[1].1, | ||
| 39 | five: symbol_multiplier * SHAPE_MULTIPLIERS[2].1, | ||
| 40 | }, | ||
| 41 | ) | ||
| 34 | }) | 42 | }) |
| 35 | .collect(); | 43 | .collect(); |
| 36 | 44 | ||
| @@ -116,17 +124,15 @@ impl SlotsGame { | |||
| 116 | let p4 = 5.0 / 7776.0; | 124 | let p4 = 5.0 / 7776.0; |
| 117 | let p5 = 1.0 / 7776.0; | 125 | let p5 = 1.0 / 7776.0; |
| 118 | 126 | ||
| 119 | let per_line: f64 = self | 127 | let symbol_sum: f64 = SYMBOL_MULTIPLIERS |
| 120 | .payouts | 128 | .iter() |
| 121 | .values() | 129 | .map(|(_, multiplier)| *multiplier as f64) |
| 122 | .map(|payout| { | ||
| 123 | p3 * payout.three as f64 | ||
| 124 | + p4 * payout.four as f64 | ||
| 125 | + p5 * payout.five as f64 | ||
| 126 | }) | ||
| 127 | .sum(); | 130 | .sum(); |
| 131 | let shape_ev = p3 * SHAPE_MULTIPLIERS[0].1 as f64 | ||
| 132 | + p4 * SHAPE_MULTIPLIERS[1].1 as f64 | ||
| 133 | + p5 * SHAPE_MULTIPLIERS[2].1 as f64; | ||
| 128 | 134 | ||
| 129 | per_line * PAYLINES.len() as f64 | 135 | symbol_sum * shape_ev * PAYLINES.len() as f64 |
| 130 | } | 136 | } |
| 131 | } | 137 | } |
| 132 | 138 | ||
