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