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/slots.rs | |
| 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/slots.rs')
| -rw-r--r-- | src/slots.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/slots.rs b/src/slots.rs new file mode 100644 index 0000000..561c449 --- /dev/null +++ b/src/slots.rs | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | //! Shared slots rules used by both the server engine and the client board. | ||
| 2 | |||
| 3 | pub const REELS: usize = 5; | ||
| 4 | pub const ROWS: usize = 3; | ||
| 5 | pub const SYMBOLS: [char; 6] = ['C', 'L', 'O', 'G', 'D', 'S']; | ||
| 6 | |||
| 7 | /// Five paylines, each entry is the row used on reel 0..4. | ||
| 8 | pub const PAYLINES: [[usize; REELS]; 5] = [ | ||
| 9 | [0, 0, 0, 0, 0], // line 1: top | ||
| 10 | [1, 1, 1, 1, 1], // line 2: middle | ||
| 11 | [2, 2, 2, 2, 2], // line 3: bottom | ||
| 12 | [0, 1, 2, 1, 0], // line 4: V | ||
| 13 | [2, 1, 0, 1, 2], // line 5: inverted V | ||
| 14 | ]; | ||
| 15 | |||
| 16 | /// (symbol, 3-of-a-kind, 4-of-a-kind, 5-of-a-kind) multipliers of total bet. | ||
| 17 | pub const PAYTABLE: [(char, u64, u64, u64); 6] = [ | ||
| 18 | ('C', 2, 5, 15), | ||
| 19 | ('L', 3, 7, 20), | ||
| 20 | ('O', 3, 8, 25), | ||
| 21 | ('G', 4, 12, 40), | ||
| 22 | ('D', 6, 18, 70), | ||
| 23 | ('S', 9, 30, 150), | ||
| 24 | ]; | ||
| 25 | |||
| 26 | /// One-line paytable rendered under the reels. | ||
| 27 | pub fn paytable_line() -> String { | ||
| 28 | let entries: Vec<String> = PAYTABLE | ||
| 29 | .iter() | ||
| 30 | .map(|(symbol, three, four, five)| format!("{symbol} {three}/{four}/{five}")) | ||
| 31 | .collect(); | ||
| 32 | format!("Pays 3/4/5 x bet: {}", entries.join(" ")) | ||
| 33 | } | ||
