mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-24 20:10:15 -08:00
general status from computer
This commit is contained in:
@@ -248,16 +248,17 @@ fn klingons_fire(galaxy: &mut Galaxy) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_damage_control(galaxy: &mut Galaxy) {
|
||||
|
||||
let ship = &mut galaxy.enterprise;
|
||||
|
||||
if ship.damaged.contains_key(systems::DAMAGE_CONTROL) {
|
||||
pub fn run_damage_control(galaxy: &Galaxy) {
|
||||
if galaxy.enterprise.damaged.contains_key(systems::DAMAGE_CONTROL) {
|
||||
view::inoperable(&systems::name_for(systems::DAMAGE_CONTROL));
|
||||
} else {
|
||||
view::damage_control(&ship);
|
||||
return;
|
||||
}
|
||||
|
||||
view::damage_control(&galaxy.enterprise);
|
||||
}
|
||||
|
||||
pub fn try_starbase_ship_repair(galaxy: &mut Galaxy) {
|
||||
let ship = &mut galaxy.enterprise;
|
||||
let quadrant = &galaxy.quadrants[ship.quadrant.as_index()];
|
||||
if ship.damaged.len() == 0 || !quadrant.docked_at_starbase(ship.sector) {
|
||||
return;
|
||||
@@ -307,6 +308,10 @@ pub fn access_computer(galaxy: &Galaxy, provided: Vec<String>) {
|
||||
|
||||
match operation {
|
||||
0 => view::galaxy_scanned_map(galaxy),
|
||||
1 => {
|
||||
view::status_report(galaxy);
|
||||
run_damage_control(galaxy);
|
||||
},
|
||||
3 => show_starbase_data(galaxy),
|
||||
5 => view::galaxy_region_map(),
|
||||
_ => todo!() // todo implement others
|
||||
|
||||
@@ -38,7 +38,10 @@ fn main() {
|
||||
systems::SHORT_RANGE_SCAN => commands::perform_short_range_scan(&galaxy),
|
||||
systems::WARP_ENGINES => commands::gather_dir_and_speed_then_move(&mut galaxy, command[1..].into()),
|
||||
systems::SHIELD_CONTROL => commands::get_amount_and_set_shields(&mut galaxy, command[1..].into()),
|
||||
systems::DAMAGE_CONTROL => commands::run_damage_control(&mut galaxy),
|
||||
systems::DAMAGE_CONTROL => {
|
||||
commands::run_damage_control(&galaxy);
|
||||
commands::try_starbase_ship_repair(&mut galaxy);
|
||||
}
|
||||
systems::LONG_RANGE_SCAN => commands::perform_long_range_scan(&mut galaxy),
|
||||
systems::COMPUTER => commands::access_computer(&galaxy, command[1..].into()),
|
||||
systems::PHASERS => commands::get_power_and_fire_phasers(&mut galaxy, command[1..].into()),
|
||||
|
||||
@@ -594,4 +594,20 @@ pub fn direction_distance(dir: f32, dist: u8) {
|
||||
"Direction = {dir}
|
||||
Distance = {dist}"
|
||||
)
|
||||
}
|
||||
|
||||
pub fn status_report(galaxy: &Galaxy) {
|
||||
let klingon_count = galaxy.remaining_klingons();
|
||||
let star_bases = galaxy.remaining_starbases();
|
||||
let time_remaining = galaxy.final_stardate - galaxy.stardate;
|
||||
let mut plural_starbase = "";
|
||||
if star_bases > 1 {
|
||||
plural_starbase = "s";
|
||||
}
|
||||
|
||||
println!(" Status report:
|
||||
Klingons left: {klingon_count}
|
||||
Mission must be completed in {time_remaining} stardates.
|
||||
The Federation is maintaining {star_bases} starbase{plural_starbase} in the galaxy.
|
||||
")
|
||||
}
|
||||
@@ -30,9 +30,9 @@ Started after movement and display of stats was finished (no energy management o
|
||||
- [x] torpedoes
|
||||
- [ ] computer
|
||||
- [x] 0 - output of all short and long range scans (requires tracking if a system has been scanned)
|
||||
- [ ] 1 - klingons, starbases, stardate and damage control
|
||||
- [x] 1 - klingons, starbases, stardate and damage control
|
||||
- [ ] 2 - photon torpedo data: direction and distance to all local klingons
|
||||
- [ ] 3 - starbase distance and dir locally
|
||||
- [x] 3 - starbase distance and dir locally
|
||||
- [ ] 4 - direction/distance calculator (useful for nav actions I guess)
|
||||
- [x] 5 - galactic name map
|
||||
|
||||
|
||||
Reference in New Issue
Block a user