implemented getting stranded

This commit is contained in:
Christopher
2023-03-02 19:08:21 +13:00
parent d76b048236
commit 2360bfd0c2
4 changed files with 18 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ fn main() {
_ => view::print_command_help()
}
if galaxy.enterprise.destroyed { // todo: also check if stranded
if galaxy.enterprise.destroyed || galaxy.enterprise.check_stranded() {
view::end_game_failure(&galaxy);
// todo check if can restart
break;

View File

@@ -93,6 +93,14 @@ impl Enterprise {
self.damaged.entry(system.to_string()).and_modify(|d| *d += amount);
return false;
}
pub fn check_stranded(&self) -> bool {
if self.total_energy < 10 || (self.total_energy - self.shields < 10 && self.damaged.contains_key(systems::SHIELD_CONTROL)) {
view::stranded();
return true;
}
return false;
}
}
pub mod systems {

View File

@@ -251,3 +251,9 @@ pub fn long_range_scan(galaxy: &Galaxy) {
println!("{:-^19}", "");
}
}
pub fn stranded() {
println!("** FATAL ERROR ** You've just stranded your ship in space
You have insufficient maneuvering energy, and shield control
is presently incapable of cross-circuiting to engine room!!")
}

View File

@@ -14,8 +14,8 @@ Started after movement and display of stats was finished (no energy management o
- [x] subsystem damage
- [x] and support for reports
- [x] random system damage or repairs on move
- [ ] lrs?
- [ ] stranded...
- [x] lrs?
- [x] stranded...
- [ ] stop before hitting an object
- when moving across a sector, the enterprise should stop before it runs into something
- the current move is a jump, which makes this problematic. would need to rewrite it
@@ -29,3 +29,4 @@ Started after movement and display of stats was finished (no energy management o
- [ ] restarting the game
- [ ] time progression
- check all areas where time should move, and adjust accordingly
- [ ] intro instructions