From c4d4f820ac72a42d903d90bc33f3e29b16befd08 Mon Sep 17 00:00:00 2001 From: Christopher Date: Sun, 5 Mar 2023 07:49:25 +1300 Subject: [PATCH] work on some computer functions --- 84_Super_Star_Trek/rust/src/commands.rs | 16 ++++++++++++++++ 84_Super_Star_Trek/rust/src/view.rs | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/84_Super_Star_Trek/rust/src/commands.rs b/84_Super_Star_Trek/rust/src/commands.rs index cc79dffb..cf427310 100644 --- a/84_Super_Star_Trek/rust/src/commands.rs +++ b/84_Super_Star_Trek/rust/src/commands.rs @@ -307,11 +307,27 @@ pub fn access_computer(galaxy: &Galaxy, provided: Vec) { match operation { 0 => view::galaxy_scanned_map(galaxy), + 3 => show_starbase_data(galaxy), 5 => view::galaxy_region_map(), _ => todo!() // todo implement others } } +fn show_starbase_data(galaxy: &Galaxy) { + let quadrant = &galaxy.quadrants[galaxy.enterprise.quadrant.as_index()]; + match &quadrant.star_base { + None => { + view::no_local_starbase(); + return; + }, + Some(s) => { + view::starbase_report(); + let pos = s.sector; + // calulcate direction and distance then print + } + } +} + pub fn get_power_and_fire_phasers(galaxy: &mut Galaxy, provided: Vec) { if galaxy.enterprise.damaged.contains_key(systems::PHASERS) { view::inoperable(&systems::name_for(systems::PHASERS)); diff --git a/84_Super_Star_Trek/rust/src/view.rs b/84_Super_Star_Trek/rust/src/view.rs index 22f397ef..75ad1924 100644 --- a/84_Super_Star_Trek/rust/src/view.rs +++ b/84_Super_Star_Trek/rust/src/view.rs @@ -579,4 +579,12 @@ court martial!") That does it, Captain!! You are hereby relieved of command and sentenced to 99 stardates at hard labor on Cygnus 12!!") } +} + +pub fn no_local_starbase() { + println!("Mr. Spock reports, 'Sensors show no starbases in this quadrant.'") +} + +pub fn starbase_report() { + println!("From Enterprise to Starbase:'") } \ No newline at end of file