GUI, game: fixed wrong number of targets in stack ability for some use cases (example: cumulative upkeep, close #12824)

This commit is contained in:
Oleg Agafonov 2024-09-07 20:49:25 +04:00
parent 8bd7e346fb
commit 2fc4e94b3a
2 changed files with 12 additions and 13 deletions

View file

@ -1134,13 +1134,13 @@ public class CardView extends SimpleCardView {
this.targets = new ArrayList<>();
}
// need only unique targets for arrow drawning
Set<UUID> newTargets = new HashSet<>();
// need only unique targets for arrow drawing
Set<UUID> uniqueTarget = new LinkedHashSet<>(); // use linked, so it will use stable sort order
// from normal targets
for (Target target : targets) {
if (target.isChosen(game)) {
newTargets.addAll(target.getTargets());
uniqueTarget.addAll(target.getTargets());
}
}
@ -1151,9 +1151,9 @@ public class CardView extends SimpleCardView {
.map(p -> p.getTargets(game, source))
.flatMap(Collection::stream)
.collect(Collectors.toList());
newTargets.addAll(fromPointers);
uniqueTarget.addAll(fromPointers);
this.targets.addAll(newTargets);
this.targets.addAll(uniqueTarget);
}
private void setOriginalValues(MageObject object) {