mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-25 20:34:32 -08:00
minor tweak to fix another underflow issue
This commit is contained in:
@@ -39,7 +39,7 @@ fn main() {
|
||||
_ => view::print_command_help()
|
||||
}
|
||||
|
||||
if galaxy.enterprise.destroyed || galaxy.enterprise.check_stranded() || galaxy.stardate >= galaxy.final_stardate {
|
||||
if galaxy.enterprise.destroyed || galaxy.enterprise.is_stranded() || galaxy.stardate >= galaxy.final_stardate {
|
||||
view::end_game_failure(&galaxy);
|
||||
if galaxy.remaining_klingons() > 0 && galaxy.remaining_starbases() > 0 && galaxy.stardate < galaxy.final_stardate {
|
||||
view::replay();
|
||||
|
||||
@@ -58,13 +58,13 @@ impl Enterprise {
|
||||
|
||||
view::enterprise_hit(&hit_strength, §or);
|
||||
|
||||
self.shields = (self.shields - hit_strength).max(0);
|
||||
|
||||
if self.shields <= 0 {
|
||||
if self.shields <= hit_strength {
|
||||
view::enterprise_destroyed();
|
||||
self.destroyed = true
|
||||
}
|
||||
|
||||
self.shields -= hit_strength;
|
||||
|
||||
view::shields_hit(self.shields);
|
||||
|
||||
if hit_strength >= 20 {
|
||||
@@ -100,7 +100,7 @@ impl Enterprise {
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn check_stranded(&self) -> bool {
|
||||
pub fn is_stranded(&self) -> bool {
|
||||
if self.total_energy < 10 || (self.shields + 10 > self.total_energy && self.damaged.contains_key(systems::SHIELD_CONTROL)) {
|
||||
view::stranded();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user