mons_rust/models/
config.rs

1use crate::*;
2use std::collections::{HashMap, HashSet};
3
4pub struct Config;
5
6impl Config {
7    pub const BOARD_SIZE: i32 = 11;
8    pub const TARGET_SCORE: i32 = 5;
9
10    pub const MONS_MOVES_PER_TURN: i32 = 5;
11    pub const MANA_MOVES_PER_TURN: i32 = 1;
12    pub const ACTIONS_PER_TURN: i32 = 1;
13
14    pub fn squares() -> std::collections::HashMap<Location, Square> {
15        use Square::*;
16        let mut squares = std::collections::HashMap::new();
17        squares.insert(Location::new(0, 0), ManaPool { color: Color::Black });
18        squares.insert(Location::new(0, 10), ManaPool { color: Color::Black });
19        squares.insert(Location::new(10, 0), ManaPool { color: Color::White });
20        squares.insert(Location::new(10, 10), ManaPool { color: Color::White });
21
22        squares.insert(Location::new(0, 3), MonBase { kind: MonKind::Mystic, color: Color::Black });
23        squares.insert(Location::new(0, 4), MonBase { kind: MonKind::Spirit, color: Color::Black });
24        squares.insert(Location::new(0, 5), MonBase { kind: MonKind::Drainer, color: Color::Black });
25        squares.insert(Location::new(0, 6), MonBase { kind: MonKind::Angel, color: Color::Black });
26        squares.insert(Location::new(0, 7), MonBase { kind: MonKind::Demon, color: Color::Black });
27        
28        squares.insert(Location::new(10, 3), MonBase { kind: MonKind::Demon, color: Color::White });
29        squares.insert(Location::new(10, 4), MonBase { kind: MonKind::Angel, color: Color::White });
30        squares.insert(Location::new(10, 5), MonBase { kind: MonKind::Drainer, color: Color::White });
31        squares.insert(Location::new(10, 6), MonBase { kind: MonKind::Spirit, color: Color::White });
32        squares.insert(Location::new(10, 7), MonBase { kind: MonKind::Mystic, color: Color::White });
33
34        squares.insert(Location::new(3, 4), ManaBase { color: Color::Black });
35        squares.insert(Location::new(3, 6), ManaBase { color: Color::Black });
36        squares.insert(Location::new(7, 4), ManaBase { color: Color::White });
37        squares.insert(Location::new(7, 6), ManaBase { color: Color::White });
38        squares.insert(Location::new(4, 3), ManaBase { color: Color::Black });
39        squares.insert(Location::new(4, 5), ManaBase { color: Color::Black });
40        squares.insert(Location::new(4, 7), ManaBase { color: Color::Black });
41        squares.insert(Location::new(6, 3), ManaBase { color: Color::White });
42        squares.insert(Location::new(6, 5), ManaBase { color: Color::White });
43        squares.insert(Location::new(6, 7), ManaBase { color: Color::White });
44
45        squares.insert(Location::new(5, 0), ConsumableBase);
46        squares.insert(Location::new(5, 10), ConsumableBase);
47        squares.insert(Location::new(5, 5), SupermanaBase);
48
49        squares
50    }
51
52    pub fn initial_items() -> HashMap<Location, Item> {
53        Self::squares().iter().filter_map(|(location, square)| {
54            match square {
55                Square::MonBase { kind, color } => Some((
56                    *location,
57                    Item::Mon {
58                        mon: Mon::new(*kind, *color, 0),
59                    },
60                )),
61                Square::ManaBase { color } => Some((
62                    *location,
63                    Item::Mana {
64                        mana: Mana::Regular(*color),
65                    },
66                )),
67                Square::SupermanaBase => Some((
68                    *location,
69                    Item::Mana {
70                        mana: Mana::Supermana,
71                    },
72                )),
73                Square::ConsumableBase => Some((
74                    *location,
75                    Item::Consumable {
76                        consumable: Consumable::BombOrPotion,
77                    },
78                )),
79                _ => None,
80            }
81        }).collect()
82    }
83
84    pub const BOARD_CENTER_INDEX: i32 = Self::BOARD_SIZE / 2;
85    pub const MAX_LOCATION_INDEX: i32 = Self::BOARD_SIZE - 1;
86
87    pub fn mons_bases() -> HashSet<Location> {
88        Self::squares().iter().filter_map(|(location, square)| {
89            match square {
90                Square::MonBase { .. } => Some(*location),
91                _ => None,
92            }
93        }).collect()
94    }
95}