mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Fix division by zero error in PossibleTargetSelector.
This commit is contained in:
@@ -40,15 +40,17 @@ public class PossibleTargetSelector {
|
|||||||
// Divide up counters, since AI is expected to do this. For now,
|
// Divide up counters, since AI is expected to do this. For now,
|
||||||
// divided evenly with left-overs going to the first target.
|
// divided evenly with left-overs going to the first target.
|
||||||
if (sa.hasParam("DividedAsYouChoose")) {
|
if (sa.hasParam("DividedAsYouChoose")) {
|
||||||
final String amountStr = sa.getParam("CounterNum");
|
|
||||||
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
|
||||||
final int targetCount = sa.getTargets().getTargetCards().size();
|
final int targetCount = sa.getTargets().getTargetCards().size();
|
||||||
final int amountPerCard = amount / sa.getTargets().getTargetCards().size();
|
if (targetCount > 0) {
|
||||||
int amountLeftOver = amount - (amountPerCard * targetCount);
|
final String amountStr = sa.getParam("CounterNum");
|
||||||
final TargetRestrictions tgtRes = sa.getTargetRestrictions();
|
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), amountStr, sa);
|
||||||
for (GameObject target : sa.getTargets().getTargets()) {
|
final int amountPerCard = amount / targetCount;
|
||||||
tgtRes.addDividedAllocation(target, amountPerCard + amountLeftOver);
|
int amountLeftOver = amount - (amountPerCard * targetCount);
|
||||||
amountLeftOver = 0;
|
final TargetRestrictions tgtRes = sa.getTargetRestrictions();
|
||||||
|
for (GameObject target : sa.getTargets().getTargets()) {
|
||||||
|
tgtRes.addDividedAllocation(target, amountPerCard + amountLeftOver);
|
||||||
|
amountLeftOver = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user