Fix updateTarget (#7927)

* Fix meld exiling missing half
This commit is contained in:
tool4ever
2025-07-05 06:58:26 +00:00
committed by GitHub
parent 01d22c26f4
commit 3b9867c537
3 changed files with 18 additions and 17 deletions

View File

@@ -645,7 +645,8 @@ public class GameAction {
// Ask controller if it wants to be on top or bottom of other meld.
unmeldPosition++;
}
changeZone(null, zoneTo, unmeld, position, cause, params);
unmeld = changeZone(null, zoneTo, unmeld, position, cause, params);
storeChangesZoneAll(unmeld, zoneFrom, zoneTo, params);
}
} else if (toBattlefield) {
for (Player p : game.getPlayers()) {

View File

@@ -37,7 +37,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
final Player chooser = sa.hasParam("Chooser") ? getDefinedPlayersOrTargeted(sa, "Chooser").get(0) : activator;
final MagicStack stack = activator.getGame().getStack();
for (final SpellAbility tgtSA : sas) {
SpellAbilityStackInstance si = stack.getInstanceMatchingSpellAbilityID(tgtSA);
if (si == null) {
@@ -72,8 +72,8 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
// 2. prepare new target choices
SpellAbilityStackInstance replaceIn = chosenTarget.getKey();
GameObject oldTarget = chosenTarget.getValue();
TargetChoices oldTargetBlock = replaceIn.getTargetChoices();
TargetChoices newTargetBlock = oldTargetBlock.clone();
TargetChoices newTargetBlock = replaceIn.getTargetChoices();
TargetChoices oldTargetBlock = newTargetBlock.clone();
// gets the divided value from old target
Integer div = oldTargetBlock.getDividedValue(oldTarget);
// 3. test if updated choices would be correct.
@@ -87,7 +87,7 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
if (div != null) {
newTargetBlock.addDividedAllocation(newTarget, div);
}
replaceIn.updateTarget(newTargetBlock, sa.getHostCard());
replaceIn.updateTarget(oldTargetBlock, sa.getHostCard());
}
} else {
while (changingTgtSI != null) {
@@ -104,25 +104,26 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
if (candidates.isEmpty()) {
return;
}
changingTgtSA.resetTargets();
GameEntity choice = Aggregates.random(candidates);
TargetChoices oldTarget = changingTgtSA.getTargets();
changingTgtSA.resetTargets();
changingTgtSA.getTargets().add(choice);
if (changingTgtSA.isDividedAsYouChoose()) {
changingTgtSA.addDividedAllocation(choice, div);
}
changingTgtSI.updateTarget(changingTgtSA.getTargets(), sa.getHostCard());
changingTgtSI.updateTarget(oldTarget, sa.getHostCard());
}
else if (sa.hasParam("DefinedMagnet")) {
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa, "DefinedMagnet"), null);
if (newTarget != null && changingTgtSA.canTarget(newTarget)) {
int div = changingTgtSA.getTotalDividedValue();
TargetChoices oldTarget = changingTgtSA.getTargets();
changingTgtSA.resetTargets();
changingTgtSA.getTargets().add(newTarget);
changingTgtSI.updateTarget(changingTgtSA.getTargets(), sa.getHostCard());
if (changingTgtSA.isDividedAsYouChoose()) {
changingTgtSA.addDividedAllocation(newTarget, div);
}
changingTgtSI.updateTarget(oldTarget, sa.getHostCard());
}
} else {
// Update targets, with a potential new target
@@ -132,8 +133,9 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
source = changingTgtSA.getTargetCard();
}
Predicate<GameObject> filter = sa.hasParam("TargetRestriction") ? GameObjectPredicates.restriction(sa.getParam("TargetRestriction").split(","), activator, source, sa) : null;
TargetChoices newTarget = chooser.getController().chooseNewTargetsFor(changingTgtSA, filter, false);
changingTgtSI.updateTarget(newTarget, sa.getHostCard());
TargetChoices oldTarget = changingTgtSA.getTargets();
chooser.getController().chooseNewTargetsFor(changingTgtSA, filter, false);
changingTgtSI.updateTarget(oldTarget, sa.getHostCard());
}
}
changingTgtSI = changingTgtSI.getSubInstance();

View File

@@ -133,18 +133,16 @@ public class SpellAbilityStackInstance implements IIdentifiable, IHasCardView {
return ability.getTargets();
}
public void updateTarget(TargetChoices target, Card cause) {
if (target != null) {
TargetChoices oldTarget = ability.getTargets();
ability.setTargets(target);
public void updateTarget(TargetChoices oldTC, Card cause) {
if (oldTC != null) {
stackDescription = ability.getStackDescription();
view.updateTargetCards(this);
view.updateTargetPlayers(this);
view.updateText(this);
Set<GameObject> distinctObjects = Sets.newHashSet();
for (final GameObject tgt : target) {
if (oldTarget != null && oldTarget.contains(tgt)) {
for (final GameObject tgt : ability.getTargets()) {
if (oldTC.contains(tgt)) {
// it was an old target, so don't trigger becomes target
continue;
}