triplea-game / triplea

TripleA is a turn based strategy game and board game engine, similar to Axis & Allies or Risk.
https://triplea-game.org/
GNU General Public License v3.0
1.3k stars 387 forks source link

Fix division by zero and check for isFinite() to fix comparator issue. #12697

Closed asvitkine closed 2 weeks ago

asvitkine commented 2 weeks ago

The check was intended to verify whether https://github.com/triplea-game/triplea/issues/12693 was caused by non-finite values. However, tests caught that this could actually trigger due to a division by zero. I suspect this should therefore fix https://github.com/triplea-game/triplea/issues/12693

Notes to Reviewer

asvitkine commented 2 weeks ago

Aha, looks like this precondition actually failed in testAiGameMovingConsumedUnitsToFactories! So that does show it's probably this that is responsible. Will need to debug.