Skip to content

Commit

Permalink
Small cleanup to default casualty logic.
Browse files Browse the repository at this point in the history
No logic changes since `numSelectedCasualties ` was equivalent to `defaultCasualtySelection.size()` already.
  • Loading branch information
asvitkine committed Jul 5, 2024
1 parent 09238fb commit 495ece8
Showing 1 changed file with 3 additions and 5 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
if (numSelectedCasualties >= hits) {
final int numSelectedCasualties = defaultCasualtySelection.size();
if (defaultCasualtySelection.size() >= 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 495ece8

Please sign in to comment.