mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
GUI, game: fixed wrong number of targets in stack ability for some use cases (example: cumulative upkeep, close #12824)
This commit is contained in:
parent
8bd7e346fb
commit
2fc4e94b3a
2 changed files with 12 additions and 13 deletions
|
|
@ -1134,13 +1134,13 @@ public class CardView extends SimpleCardView {
|
||||||
this.targets = new ArrayList<>();
|
this.targets = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// need only unique targets for arrow drawning
|
// need only unique targets for arrow drawing
|
||||||
Set<UUID> newTargets = new HashSet<>();
|
Set<UUID> uniqueTarget = new LinkedHashSet<>(); // use linked, so it will use stable sort order
|
||||||
|
|
||||||
// from normal targets
|
// from normal targets
|
||||||
for (Target target : targets) {
|
for (Target target : targets) {
|
||||||
if (target.isChosen(game)) {
|
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))
|
.map(p -> p.getTargets(game, source))
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
newTargets.addAll(fromPointers);
|
uniqueTarget.addAll(fromPointers);
|
||||||
|
|
||||||
this.targets.addAll(newTargets);
|
this.targets.addAll(uniqueTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOriginalValues(MageObject object) {
|
private void setOriginalValues(MageObject object) {
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,7 @@ import mage.target.Target;
|
||||||
import mage.target.targetpointer.TargetPointer;
|
import mage.target.targetpointer.TargetPointer;
|
||||||
import mage.util.GameLog;
|
import mage.util.GameLog;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -86,15 +84,16 @@ public class StackAbilityView extends CardView {
|
||||||
if (!mode.getTargets().isEmpty()) {
|
if (!mode.getTargets().isEmpty()) {
|
||||||
addTargets(mode.getTargets(), mode.getEffects(), ability, game);
|
addTargets(mode.getTargets(), mode.getEffects(), ability, game);
|
||||||
} else {
|
} else {
|
||||||
List<UUID> targetList = new ArrayList<>();
|
// need only unique targets for arrow drawing
|
||||||
|
Set<UUID> uniqueTargets = new LinkedHashSet<>(); // use linked, so it will use stable sort order
|
||||||
for (Effect effect : mode.getEffects()) {
|
for (Effect effect : mode.getEffects()) {
|
||||||
TargetPointer targetPointer = effect.getTargetPointer();
|
TargetPointer targetPointer = effect.getTargetPointer();
|
||||||
targetList.addAll(targetPointer.getTargets(game, ability));
|
uniqueTargets.addAll(targetPointer.getTargets(game, ability));
|
||||||
}
|
}
|
||||||
if (!targetList.isEmpty()) {
|
if (!uniqueTargets.isEmpty()) {
|
||||||
overrideTargets(targetList);
|
overrideTargets(new ArrayList<>(uniqueTargets));
|
||||||
|
|
||||||
for (UUID uuid : targetList) {
|
for (UUID uuid : uniqueTargets) {
|
||||||
MageObject mageObject = game.getObject(uuid);
|
MageObject mageObject = game.getObject(uuid);
|
||||||
if (mageObject != null) {
|
if (mageObject != null) {
|
||||||
if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) {
|
if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue