mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-09 11:46:24 -08:00
30 lines
510 B
Rust
30 lines
510 B
Rust
#[derive(Debug)]
|
|
pub struct Coordinate {
|
|
x: usize,
|
|
y: usize,
|
|
pub state: CoordState,
|
|
}
|
|
|
|
impl Coordinate {
|
|
pub fn new(pos: (usize, usize), has_mugwump: bool) -> Self {
|
|
let state = if has_mugwump {
|
|
CoordState::HasMugwump
|
|
} else {
|
|
CoordState::Normal
|
|
};
|
|
|
|
Coordinate {
|
|
x: pos.0,
|
|
y: pos.1,
|
|
state,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum CoordState {
|
|
Normal,
|
|
HasMugwump,
|
|
Checked,
|
|
}
|