diff options
Diffstat (limited to '')
| -rw-r--r-- | src/slots.rs | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/src/slots.rs b/src/slots.rs index a3b4ef4..9e41f05 100644 --- a/src/slots.rs +++ b/src/slots.rs | |||
| @@ -13,33 +13,38 @@ pub const PAYLINES: [[usize; REELS]; 5] = [ | |||
| 13 | [2, 1, 0, 1, 2], // line 5: inverted V | 13 | [2, 1, 0, 1, 2], // line 5: inverted V |
| 14 | ]; | 14 | ]; |
| 15 | 15 | ||
| 16 | /// (symbol, 3-of-a-kind, 4-of-a-kind, 5-of-a-kind) multipliers of total bet. | 16 | pub const LINE_NAMES: [&str; 5] = ["top", "middle", "bottom", "V", "inverted V"]; |
| 17 | pub const PAYTABLE: [(char, u64, u64, u64); 6] = [ | 17 | |
| 18 | ('C', 2, 5, 15), | 18 | /// Symbol value multipliers. |
| 19 | ('L', 3, 7, 20), | 19 | pub const SYMBOL_MULTIPLIERS: [(char, u64); 6] = [ |
| 20 | ('O', 3, 8, 25), | 20 | ('C', 1), |
| 21 | ('G', 4, 12, 40), | 21 | ('L', 2), |
| 22 | ('D', 6, 18, 70), | 22 | ('O', 3), |
| 23 | ('S', 9, 30, 150), | 23 | ('G', 4), |
| 24 | ('D', 6), | ||
| 25 | ('S', 10), | ||
| 24 | ]; | 26 | ]; |
| 25 | 27 | ||
| 26 | /// Paytable rendered under the reels, split so it fits a narrow terminal. | 28 | /// (match length, shape multiplier): 3, 4 or 5 of a kind. |
| 29 | pub const SHAPE_MULTIPLIERS: [(usize, u64); 3] = [(3, 1), (4, 3), (5, 14)]; | ||
| 30 | |||
| 31 | /// Paytable rendered under the reels. | ||
| 32 | /// | ||
| 33 | /// `payout = bet * symbol_multiplier * shape_multiplier`. | ||
| 27 | pub fn paytable_lines() -> Vec<String> { | 34 | pub fn paytable_lines() -> Vec<String> { |
| 28 | let entries: Vec<String> = PAYTABLE | 35 | let symbols = SYMBOL_MULTIPLIERS |
| 36 | .iter() | ||
| 37 | .map(|(symbol, multiplier)| format!("{symbol}{multiplier}")) | ||
| 38 | .collect::<Vec<_>>() | ||
| 39 | .join(" "); | ||
| 40 | let shapes = SHAPE_MULTIPLIERS | ||
| 29 | .iter() | 41 | .iter() |
| 30 | .map(|(symbol, three, four, five)| format!("{symbol} {three}/{four}/{five}")) | 42 | .map(|(length, multiplier)| format!("{length}:{multiplier}")) |
| 31 | .collect(); | 43 | .collect::<Vec<_>>() |
| 44 | .join(" "); | ||
| 32 | 45 | ||
| 33 | entries | 46 | vec![ |
| 34 | .chunks(3) | 47 | "Pays bet x symbol x shape".to_string(), |
| 35 | .enumerate() | 48 | format!("Symbol {symbols} Shape {shapes}"), |
| 36 | .map(|(index, chunk)| { | 49 | ] |
| 37 | let prefix = if index == 0 { | ||
| 38 | "Pays 3/4/5 x bet: " | ||
| 39 | } else { | ||
| 40 | "" | ||
| 41 | }; | ||
| 42 | format!("{}{}", prefix, chunk.join(" ")) | ||
| 43 | }) | ||
| 44 | .collect() | ||
| 45 | } | 50 | } |
