mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-15 22:42:38 -08:00
43 lines
768 B
Rust
43 lines
768 B
Rust
|
|
pub struct Galaxy {
|
|
pub quadrants: Vec<Quadrant>,
|
|
pub enterprise: Enterprise,
|
|
pub game_status: GameStatus
|
|
}
|
|
|
|
pub struct Pos(u8, u8);
|
|
|
|
impl Pos {
|
|
pub fn as_index(&self) -> usize {
|
|
(self.0 * 8 + self.1).into()
|
|
}
|
|
}
|
|
|
|
pub struct Quadrant {
|
|
pub stars: Vec<Pos>,
|
|
pub star_bases: Vec<Pos>,
|
|
pub klingons: Vec<Klingon>
|
|
}
|
|
|
|
pub struct Klingon {
|
|
pub sector: Pos
|
|
}
|
|
|
|
pub struct Enterprise {
|
|
pub quadrant: Pos,
|
|
pub sector: Pos,
|
|
}
|
|
|
|
pub enum GameStatus {
|
|
ShortRangeScan
|
|
}
|
|
|
|
impl Galaxy {
|
|
pub fn generate_new() -> Self {
|
|
Galaxy {
|
|
quadrants: Vec::new(),
|
|
enterprise: Enterprise { quadrant: Pos(0,0), sector: Pos(0,0) },
|
|
game_status: GameStatus::ShortRangeScan
|
|
}
|
|
}
|
|
} |