Merge branch 'master' into 'master'

fix divided allocation

See merge request core-developers/forge!4605
This commit is contained in:
Anthony Calosa
2021-04-26 20:01:36 +00:00

View File

@@ -866,17 +866,16 @@ public class CountersPutAi extends SpellAbilityAi {
choice = Aggregates.random(list); choice = Aggregates.random(list);
} }
} }
if (choice != null && divided) { }
int alloc = Math.max(amount / totalTargets, 1); if (choice != null && divided) {
if (sa.getTargets().size() == Math.min(totalTargets, sa.getMaxTargets()) - 1) { int alloc = Math.max(amount / totalTargets, 1);
sa.addDividedAllocation(choice, left); if (sa.getTargets().size() == Math.min(totalTargets, sa.getMaxTargets()) - 1) {
} else { sa.addDividedAllocation(choice, left);
sa.addDividedAllocation(choice, alloc); } else {
left -= alloc; sa.addDividedAllocation(choice, alloc);
} left -= alloc;
} }
} }
if (choice != null) { if (choice != null) {
sa.getTargets().add(choice); sa.getTargets().add(choice);
list.remove(choice); list.remove(choice);