mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-16 15:03:50 -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) {
|
pub fn run_damage_control(galaxy: &Galaxy) {
|
||||||
|
if galaxy.enterprise.damaged.contains_key(systems::DAMAGE_CONTROL) {
|
||||||
let ship = &mut galaxy.enterprise;
|
|
||||||
|
|
||||||
if ship.damaged.contains_key(systems::DAMAGE_CONTROL) {
|
|
||||||
view::inoperable(&systems::name_for(systems::DAMAGE_CONTROL));
|
view::inoperable(&systems::name_for(systems::DAMAGE_CONTROL));
|
||||||
} else {
|
return;
|
||||||
view::damage_control(&ship);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()];
|
let quadrant = &galaxy.quadrants[ship.quadrant.as_index()];
|
||||||
if ship.damaged.len() == 0 || !quadrant.docked_at_starbase(ship.sector) {
|
if ship.damaged.len() == 0 || !quadrant.docked_at_starbase(ship.sector) {
|
||||||
return;
|
return;
|
||||||
@@ -307,6 +308,10 @@ pub fn access_computer(galaxy: &Galaxy, provided: Vec<String>) {
|
|||||||
|
|
||||||
match operation {
|
match operation {
|
||||||
0 => view::galaxy_scanned_map(galaxy),
|
0 => view::galaxy_scanned_map(galaxy),
|
||||||
|
1 => {
|
||||||
|
view::status_report(galaxy);
|
||||||
|
run_damage_control(galaxy);
|
||||||
|
},
|
||||||
3 => show_starbase_data(galaxy),
|
3 => show_starbase_data(galaxy),
|
||||||
5 => view::galaxy_region_map(),
|
5 => view::galaxy_region_map(),
|
||||||
_ => todo!() // todo implement others
|
_ => todo!() // todo implement others
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ fn main() {
|
|||||||
systems::SHORT_RANGE_SCAN => commands::perform_short_range_scan(&galaxy),
|
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::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::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::LONG_RANGE_SCAN => commands::perform_long_range_scan(&mut galaxy),
|
||||||
systems::COMPUTER => commands::access_computer(&galaxy, command[1..].into()),
|
systems::COMPUTER => commands::access_computer(&galaxy, command[1..].into()),
|
||||||
systems::PHASERS => commands::get_power_and_fire_phasers(&mut 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}
|
"Direction = {dir}
|
||||||
Distance = {dist}"
|
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
|
- [x] torpedoes
|
||||||
- [ ] computer
|
- [ ] computer
|
||||||
- [x] 0 - output of all short and long range scans (requires tracking if a system has been scanned)
|
- [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
|
- [ ] 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)
|
- [ ] 4 - direction/distance calculator (useful for nav actions I guess)
|
||||||
- [x] 5 - galactic name map
|
- [x] 5 - galactic name map
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user