mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 15:37:51 -08:00
added proper help
This commit is contained in:
@@ -97,6 +97,20 @@ fn find_end_quadrant_sector(start_quadrant: Pos, start_sector: Pos, course: u8,
|
||||
EndPosition { quadrant, sector, hit_edge }
|
||||
}
|
||||
|
||||
pub fn move_klingons_and_fire(galaxy: &mut Galaxy) {
|
||||
let quadrant = &mut galaxy.quadrants[galaxy.enterprise.quadrant.as_index()];
|
||||
for k in 0..quadrant.klingons.len() {
|
||||
let new_sector = quadrant.find_empty_sector();
|
||||
quadrant.klingons[k].sector = new_sector;
|
||||
}
|
||||
|
||||
// todo: check if enterprise is protected by a starbase
|
||||
|
||||
for k in 0..quadrant.klingons.len() {
|
||||
quadrant.klingons[k].fire_on(&mut galaxy.enterprise);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -170,4 +184,4 @@ mod tests {
|
||||
assert_eq!(end.sector, Pos(1,0), "right sector");
|
||||
assert!(!end.hit_edge)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,18 +47,7 @@ fn gather_dir_and_speed_then_move(galaxy: &mut Galaxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
let quadrant = &mut galaxy.quadrants[galaxy.enterprise.quadrant.as_index()];
|
||||
for k in 0..quadrant.klingons.len() {
|
||||
let new_sector = quadrant.find_empty_sector();
|
||||
quadrant.klingons[k].sector = new_sector;
|
||||
}
|
||||
|
||||
// todo: check if enterprise is protected by a starbase
|
||||
|
||||
for k in 0..quadrant.klingons.len() {
|
||||
quadrant.klingons[k].fire_on(&mut galaxy.enterprise);
|
||||
}
|
||||
|
||||
commands::move_klingons_and_fire(galaxy);
|
||||
if galaxy.enterprise.condition == Condition::Destroyed {
|
||||
return;
|
||||
}
|
||||
@@ -88,6 +77,16 @@ fn prompt_value<T: FromStr + PartialOrd>(prompt_text: &str, min: T, max: T) -> O
|
||||
}
|
||||
|
||||
fn print_command_help() {
|
||||
println!("valid commands are just SRS and NAV at the mo")
|
||||
println!("Enter one of the following:
|
||||
NAV (To set course)
|
||||
SRS (For short range sensor scan)
|
||||
LRS (For long range sensor scan)
|
||||
PHA (To fire phasers)
|
||||
TOR (To fire photon torpedoes)
|
||||
SHE (To raise or lower shields)
|
||||
DAM (For damage control reports)
|
||||
COM (To call on library-computer)
|
||||
XXX (To resign your command)
|
||||
")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user