mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-06-22 22:56:08 -07:00
implemented setting shields
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.'")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user