1use crate::Direction;
4
5#[derive(Clone, Copy, Debug, PartialEq)]
7pub enum UnitType {
8 Archer,
9 Captive,
10 Sludge,
11 ThickSludge,
12 Warrior,
13 Wizard,
14}
15
16impl UnitType {
17 pub fn draw(self) -> &'static str {
19 match self {
20 UnitType::Archer => "a",
21 UnitType::Captive => "C",
22 UnitType::Sludge => "s",
23 UnitType::ThickSludge => "S",
24 UnitType::Warrior => "@",
25 UnitType::Wizard => "w",
26 }
27 }
28}
29
30#[derive(Clone, Debug)]
32pub struct Unit {
33 pub unit_type: UnitType,
34 pub position: (i32, i32),
35 pub hp: (i32, i32),
36 pub atk: i32,
37 pub facing: Option<Direction>,
38}
39
40impl Unit {
41 pub fn new(unit_type: UnitType, position: (i32, i32)) -> Unit {
43 match unit_type {
44 UnitType::Archer => Unit::archer(position),
45 UnitType::Captive => Unit::captive(position),
46 UnitType::Sludge => Unit::sludge(position),
47 UnitType::ThickSludge => Unit::thick_sludge(position),
48 UnitType::Warrior => Unit::warrior(position),
49 UnitType::Wizard => Unit::wizard(position),
50 }
51 }
52
53 pub fn archer(position: (i32, i32)) -> Unit {
55 Unit {
56 unit_type: UnitType::Archer,
57 position,
58 hp: (7, 7),
59 atk: 3,
60 facing: None,
61 }
62 }
63
64 pub fn captive(position: (i32, i32)) -> Unit {
66 Unit {
67 unit_type: UnitType::Captive,
68 position,
69 hp: (1, 1),
70 atk: 0,
71 facing: None,
72 }
73 }
74
75 pub fn sludge(position: (i32, i32)) -> Unit {
77 Unit {
78 unit_type: UnitType::Sludge,
79 position,
80 hp: (12, 12),
81 atk: 3,
82 facing: None,
83 }
84 }
85
86 pub fn thick_sludge(position: (i32, i32)) -> Unit {
88 Unit {
89 unit_type: UnitType::ThickSludge,
90 position,
91 hp: (18, 18),
92 atk: 3,
93 facing: None,
94 }
95 }
96
97 pub fn warrior(position: (i32, i32)) -> Unit {
99 Unit {
100 unit_type: UnitType::Warrior,
101 position,
102 hp: (20, 20),
103 atk: 5,
104 facing: Some(Direction::Forward),
105 }
106 }
107
108 pub fn wizard(position: (i32, i32)) -> Unit {
110 Unit {
111 unit_type: UnitType::Wizard,
112 position,
113 hp: (3, 3),
114 atk: 11,
115 facing: None,
116 }
117 }
118}