mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-24 20:10:15 -08:00
implemented getting stranded
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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!!")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user