summaryrefslogtreecommitdiffstats
path: root/src/slots.rs
blob: 443444e931790b9aad731656b9363441f0cd3935 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Shared slots rules used by both the server engine and the client board.

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 const LINE_NAMES: [&str; 5] = ["top", "middle", "bottom", "V", "inverted V"];

/// Symbol value multipliers.
pub const SYMBOL_MULTIPLIERS: [(char, u64); 6] =
    [('C', 1), ('L', 2), ('O', 3), ('G', 4), ('D', 6), ('S', 10)];

/// (match length, shape multiplier): 3, 4 or 5 of a kind.
pub const SHAPE_MULTIPLIERS: [(usize, u64); 3] = [(3, 1), (4, 3), (5, 14)];

/// Paytable rendered under the reels.
///
/// `payout = bet * symbol_multiplier * shape_multiplier`.
pub fn paytable_lines() -> Vec<String> {
    let symbols = SYMBOL_MULTIPLIERS
        .iter()
        .map(|(symbol, multiplier)| format!("{symbol}{multiplier}"))
        .collect::<Vec<_>>()
        .join(" ");
    let shapes = SHAPE_MULTIPLIERS
        .iter()
        .map(|(length, multiplier)| format!("{length}:{multiplier}"))
        .collect::<Vec<_>>()
        .join(" ");

    vec![
        "Pays bet x symbol x shape".to_string(),
        format!("Symbol {symbols}   Shape {shapes}"),
    ]
}