implemented setting shields

This commit is contained in:
Christopher
2023-03-02 11:37:58 +13:00
parent ca89609c3e
commit 2feb1a9c65
3 changed files with 42 additions and 3 deletions
+22
View File
@@ -27,6 +27,7 @@ fn main() {
match command[0].to_uppercase().as_str() {
"SRS" => view::short_range_scan(&galaxy),
"NAV" => gather_dir_and_speed_then_move(&mut galaxy, command[1..].into()),
"SHE" => get_amount_and_set_shields(&mut galaxy, command[1..].into()),
_ => view::print_command_help()
}
@@ -37,6 +38,27 @@ fn main() {
}
}
fn get_amount_and_set_shields(galaxy: &mut Galaxy, provided: Vec<String>) {
// todo check for damaged module
view::energy_available(galaxy.enterprise.total_energy);
let value = param_or_prompt_value(&provided, 0, "Number of units to shields", 0, i32::MAX);
if value.is_none() {
view::shields_unchanged();
return;
}
let value = value.unwrap() as u16;
if value > galaxy.enterprise.total_energy {
view::ridiculous();
view::shields_unchanged();
return;
}
galaxy.enterprise.shields = value;
view::shields_set(value);
}
fn gather_dir_and_speed_then_move(galaxy: &mut Galaxy, provided: Vec<String>) {
let course = param_or_prompt_value(&provided, 0, "Course (1-9)?", 1, 9);
+17
View File
@@ -174,3 +174,20 @@ pub fn insuffient_warp_energy(warp_speed: f32) {
pub fn divert_energy_from_shields() {
println!("Shield Control supplies energy to complete the maneuver.")
}
pub fn energy_available(total_energy: u16) {
println!("Energy available = {{{total_energy}}}")
}
pub fn shields_unchanged() {
println!("<SHIELDS UNCHANGED>")
}
pub fn ridiculous() {
println!("Shield Control reports, 'This is not the Federation Treasury.'")
}
pub fn shields_set(value: u16) {
println!("Deflector control room report:
'Shields now at {value} units per your command.'")
}
+3 -3
View File
@@ -7,9 +7,9 @@ Started after movement and display of stats was finished (no energy management o
- [x] add intro
- [x] add entering (and starting in) sector headers
- [x] conditions and danger messages
- [ ] remove energy on move
- [ ] shields
- [ ] shield control
- [x] remove energy on move
- [x] shields
- [x] shield control
- [ ] shield hit absorption
- [ ] subsystem damage
- and support for reports