mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-31 15:07:42 -08:00
42 lines
767 B
Rust
42 lines
767 B
Rust
#![allow(dead_code)]
|
|
|
|
#[derive(Debug)]
|
|
pub struct Coordinate {
|
|
x: u8,
|
|
y: u8,
|
|
pub state: CoordState,
|
|
pub mugwump_number: u8,
|
|
}
|
|
|
|
impl Coordinate {
|
|
pub fn new(pos: (u8, u8), has_mugwump: bool, mugwump_number: i32) -> Self {
|
|
let mut mug_no = 0;
|
|
|
|
let state = if has_mugwump {
|
|
mug_no = mugwump_number;
|
|
CoordState::HasMugwump
|
|
} else {
|
|
CoordState::Normal
|
|
};
|
|
|
|
Coordinate {
|
|
x: pos.0,
|
|
y: pos.1,
|
|
state,
|
|
mugwump_number: mug_no as u8,
|
|
}
|
|
}
|
|
|
|
pub fn get_pos(&self) -> (u8, u8) {
|
|
(self.x, self.y)
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum CoordState {
|
|
Normal,
|
|
HasMugwump,
|
|
Checked,
|
|
FoundMugwump,
|
|
}
|