Fix division by zero error in PossibleTargetSelector.

This commit is contained in:
Myrd
2016-01-01 22:06:13 +00:00
parent 0b95d357d3
commit b189fd5ff9

View File

@@ -40,10 +40,11 @@ public class PossibleTargetSelector {
// Divide up counters, since AI is expected to do this. For now,
// divided evenly with left-overs going to the first target.
if (sa.hasParam("DividedAsYouChoose")) {
final int targetCount = sa.getTargets().getTargetCards().size();
if (targetCount > 0) {
final String amountStr = sa.getParam("CounterNum");
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
final int targetCount = sa.getTargets().getTargetCards().size();
final int amountPerCard = amount / sa.getTargets().getTargetCards().size();
final int amountPerCard = amount / targetCount;
int amountLeftOver = amount - (amountPerCard * targetCount);
final TargetRestrictions tgtRes = sa.getTargetRestrictions();
for (GameObject target : sa.getTargets().getTargets()) {
@@ -51,6 +52,7 @@ public class PossibleTargetSelector {
amountLeftOver = 0;
}
}
}
// TODO: smarter about multiple targets, identical targets, etc...
targetIndex++;