minor tweak to fix another underflow issue

This commit is contained in:
Christopher
2023-03-04 09:07:51 +13:00
parent 7008127806
commit 51cfce4fb8
2 changed files with 5 additions and 5 deletions

View File

@@ -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();

View File

@@ -58,13 +58,13 @@ impl Enterprise {
view::enterprise_hit(&hit_strength, &sector);
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;