Skip to content

Commit

Permalink
Small cleanup to default casualty logic. (#12696)
Browse files Browse the repository at this point in the history
* Small cleanup to default casualty logic.

No logic changes since `numSelectedCasualties ` was equivalent to `defaultCasualtySelection.size()` already.

* .
  • Loading branch information
asvitkine committed Jul 5, 2024
1 parent 09238fb commit 969993b
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,30 +263,28 @@ private static Tuple<CasualtyList, List<Unit>> getDefaultCasualties(
final List<Unit> sorted =
getCasualtyOrderOfLoss(targetsToPickFrom, player, combatValue, battlesite, costs, data);
// Remove two hit bb's selecting them first for default casualties
int numSelectedCasualties = 0;
if (allowMultipleHitsPerUnit) {
for (final Unit unit : sorted) {
// Stop if we have already selected as many hits as there are targets
final int numSelectedCasualties = defaultCasualtySelection.size();
if (numSelectedCasualties >= hits) {
return Tuple.of(defaultCasualtySelection, sorted);
}
final UnitAttachment ua = unit.getUnitAttachment();
final int extraHitPoints =
Math.min((hits - numSelectedCasualties), (ua.getHitPoints() - (1 + unit.getHits())));
for (int i = 0; i < extraHitPoints; i++) {
numSelectedCasualties++;
defaultCasualtySelection.addToDamaged(unit);
}
}
}
// Select units
for (final Unit unit : sorted) {
// Stop if we have already selected as many hits as there are targets
if (numSelectedCasualties >= hits) {
if (defaultCasualtySelection.size() >= hits) {
return Tuple.of(defaultCasualtySelection, sorted);
}
defaultCasualtySelection.addToKilled(unit);
numSelectedCasualties++;
}
return Tuple.of(defaultCasualtySelection, sorted);
}
Expand Down

0 comments on commit 969993b

Please sign in to comment.