Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert #2080 #2544

Merged
merged 1 commit into from
Oct 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/main/java/games/strategy/triplea/delegate/MustFightBattle.java
Original file line number Diff line number Diff line change
Expand Up @@ -773,13 +773,6 @@ List<IExecutable> getBattleExecutables(final boolean firstRun) {

@Override
public void execute(final ExecutionStack stack, final IDelegateBridge bridge) {
if (getBattlePower(true, m_attackingUnits, bridge, new ArrayList<>()) > 0) {
final List<Unit> unitsToRemove = new ArrayList<>();
if (getBattlePower(false, m_defendingUnits, bridge, unitsToRemove) == 0) {
remove(new ArrayList<>(Matches.getMatches(unitsToRemove, Matches.unitIsInfrastructure().invert())),
bridge, m_battleSite, true);
}
}
clearWaitingToDie(bridge);
}
});
Expand Down Expand Up @@ -2671,19 +2664,6 @@ public void unitsLostInPrecedingBattle(final IBattle battle, final Collection<Un
}
}

private int getBattlePower(final boolean attack, final List<Unit> units, final IDelegateBridge bridge,
final List<Unit> unitsToRemove) {
final Match<Unit> unitTypes = Matches.unitCanBeInBattle(attack, !m_battleSite.isWater(), 1, false, !attack, true);
final List<Unit> sortedUnits = new ArrayList<>(Matches.getMatches(units, unitTypes));
Collections.sort(sortedUnits, new UnitBattleComparator(!attack,
TuvUtils.getCostsForTuv(bridge.getPlayerId(), m_data),
TerritoryEffectHelper.getEffects(m_battleSite), m_data, false, false));
Collections.reverse(sortedUnits);
unitsToRemove.addAll(sortedUnits);
return DiceRoll.getTotalPower(DiceRoll.getUnitPowerAndRollsForNormalBattles(sortedUnits, units, !attack,
false, m_data, m_battleSite, TerritoryEffectHelper.getEffects(m_battleSite), false, null), m_data);
}

/**
* Returns a map of transport -> collection of transported units.
*/
Expand Down