Add ChangesZoneAll trigger in GameAction

This commit is contained in:
Adam Pantel
2021-04-17 15:28:56 -04:00
committed by Churrufli
parent 2fe54a28b1
commit a29ca46ca3
2 changed files with 24 additions and 4 deletions

View File

@@ -852,7 +852,24 @@ public class GameAction {
}
public final Card exile(final Card c, SpellAbility cause) {
return exile(c, cause, null);
if (c == null) {
return null;
}
return exile(new CardCollection(c), cause).get(0);
}
public final CardCollection exile(final CardCollection cards, SpellAbility cause) {
CardZoneTable table = new CardZoneTable();
CardCollection result = new CardCollection();
for (Card card : cards) {
if (cause != null) {
table.put(card.getZone().getZoneType(), ZoneType.Exile, card);
}
result.add(exile(card, cause, null));
}
if (cause != null) {
table.triggerChangesZoneAll(game, cause);
}
return result;
}
public final Card exile(final Card c, SpellAbility cause, Map<AbilityKey, Object> params) {
if (game.isCardExiled(c)) {

View File

@@ -15,6 +15,8 @@ import forge.game.zone.PlayerZoneBattlefield;
import forge.game.zone.ZoneType;
import forge.util.Localizer;
import java.util.Arrays;
public class MeldEffect extends SpellAbilityEffect {
@Override
public void resolve(SpellAbility sa) {
@@ -24,8 +26,6 @@ public class MeldEffect extends SpellAbilityEffect {
Game game = hostCard.getGame();
Player controller = sa.getActivatingPlayer();
Card primary = game.getAction().exile(hostCard, sa);
// a creature you control and own named secondary
CardCollection field = CardLists.filter(
controller.getCreaturesInPlay(),
@@ -38,7 +38,10 @@ public class MeldEffect extends SpellAbilityEffect {
Card secondary = controller.getController().chooseSingleEntityForEffect(field, sa, Localizer.getInstance().getMessage("lblChooseCardToMeld"), null);
secondary = game.getAction().exile(secondary, sa);
CardCollection exiled = new CardCollection(Arrays.asList(hostCard, secondary));
exiled = game.getAction().exile(exiled, sa);
Card primary = exiled.get(0);
secondary = exiled.get(1);
// cards has wrong name in exile
if (!primary.sharesNameWith(primName) || !secondary.sharesNameWith(secName)) {