implemented klongon data, final computer program

This commit is contained in:
Christopher
2023-03-05 14:09:28 +13:00
parent 50a4ddbcdc
commit d973dec62d
3 changed files with 28 additions and 4 deletions

View File

@@ -312,14 +312,30 @@ pub fn access_computer(galaxy: &Galaxy, provided: Vec<String>) {
view::status_report(galaxy);
run_damage_control(galaxy);
},
3 => show_starbase_data(galaxy),
2 => show_klingon_direction_data(galaxy),
3 => show_starbase_direction_data(galaxy),
4 => direction_dist_calculator(galaxy),
5 => view::galaxy_region_map(),
_ => todo!() // todo implement others
}
}
fn show_starbase_data(galaxy: &Galaxy) {
fn show_klingon_direction_data(galaxy: &Galaxy) {
let quadrant = &galaxy.quadrants[galaxy.enterprise.quadrant.as_index()];
if quadrant.klingons.len() == 0 {
view::no_local_enemies();
return;
}
view::klingon_report(quadrant.klingons.len() > 1);
let origin = galaxy.enterprise.sector;
for k in &quadrant.klingons {
let target = k.sector;
view::direction_distance(origin.direction(target), origin.dist(target))
}
}
fn show_starbase_direction_data(galaxy: &Galaxy) {
let quadrant = &galaxy.quadrants[galaxy.enterprise.quadrant.as_index()];
match &quadrant.star_base {
None => {

View File

@@ -620,4 +620,12 @@ pub fn direction_dist_intro(enterprise: &Enterprise) {
println!("Direction/distance calculator:
You are at quadrant {quadrant} sector {sector}
Please enter")
}
pub fn klingon_report(more_than_one: bool) {
let mut plural = "";
if more_than_one {
plural = "s";
}
println!("From Enterprise to Klingon battle cruiser{}", plural)
}

View File

@@ -28,10 +28,10 @@ Started after movement and display of stats was finished (no energy management o
- [x] weapons
- [x] phasers
- [x] torpedoes
- [ ] computer
- [x] computer
- [x] 0 - output of all short and long range scans (requires tracking if a system has been scanned)
- [x] 1 - klingons, starbases, stardate and damage control
- [ ] 2 - photon torpedo data: direction and distance to all local klingons
- [x] 2 - photon torpedo data: direction and distance to all local klingons
- [x] 3 - starbase distance and dir locally
- [x] 4 - direction/distance calculator (useful for nav actions I guess)
- [x] 5 - galactic name map