diff --git a/Mage.Sets/src/mage/cards/e/EtherealValkyrie.java b/Mage.Sets/src/mage/cards/e/EtherealValkyrie.java index 9a9f83918b7..1da51c68698 100644 --- a/Mage.Sets/src/mage/cards/e/EtherealValkyrie.java +++ b/Mage.Sets/src/mage/cards/e/EtherealValkyrie.java @@ -177,6 +177,7 @@ class EtherealValkyrieEffect extends OneShotEffect { foretellAbility.activate(game, true); ContinuousEffect effect = foretellAbility.new ForetellAddCostEffect(new MageObjectReference(exileCard, game)); game.addEffect(effect, source); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.FORETOLD, exileCard.getId(), null, null)); return true; } } diff --git a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java index 60929049109..6bcf3bf45e4 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java @@ -119,7 +119,10 @@ public class ForetellAbility extends SpecialAction { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && card != null) { + + // get main card id UUID mainCardId = card.getMainCard().getId(); + // retrieve the exileId of the foretold card UUID exileId = CardUtil.getExileZoneId(mainCardId.toString() + "foretellAbility", game); diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index 704d001fa14..bad2b187433 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -464,6 +464,7 @@ public class GameEvent implements Serializable { VENTURE, VENTURED, DUNGEON_COMPLETED, REMOVED_FROM_COMBAT, // targetId id of permanent removed from combat + FORETOLD, // targetId id of card foretold //custom events CUSTOM_EVENT } diff --git a/Mage/src/main/java/mage/watchers/common/ForetoldWatcher.java b/Mage/src/main/java/mage/watchers/common/ForetoldWatcher.java index 68aad21d073..f62a879d051 100644 --- a/Mage/src/main/java/mage/watchers/common/ForetoldWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/ForetoldWatcher.java @@ -6,11 +6,8 @@ import java.util.UUID; import mage.abilities.keyword.ForetellAbility; import mage.cards.Card; import mage.constants.WatcherScope; -import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.stack.Spell; -import mage.util.CardUtil; import mage.watchers.Watcher; /** @@ -21,7 +18,7 @@ public class ForetoldWatcher extends Watcher { // If foretell was activated or a card was Foretold by the controller this turn, this list stores it. Cleared at the end of the turn. private final Set foretellCardsThisTurn = new HashSet<>(); - private final Set foretoldCardsThisTurn = new HashSet<>(); + private final Set foretoldCards = new HashSet<>(); public ForetoldWatcher() { super(WatcherScope.GAME); @@ -35,41 +32,30 @@ public class ForetoldWatcher extends Watcher { && card.getAbilities(game).containsClass(ForetellAbility.class) && controllerId == event.getPlayerId()) { foretellCardsThisTurn.add(card.getId()); + foretoldCards.add(card.getId()); } } - if (event.getType() == GameEvent.EventType.SPELL_CAST - && event.getZone() == Zone.EXILED) { - Spell spell = (Spell) game.getObject(event.getTargetId()); - if (spell != null - && controllerId == event.getPlayerId()) { - UUID exileId = CardUtil.getExileZoneId(spell.getSourceId().toString() + "foretellAbility", game); - if (exileId != null) { - foretoldCardsThisTurn.add(spell.getSourceId()); - } + // Ethereal Valkyrie + if (event.getType() == GameEvent.EventType.FORETOLD) { + Card card = game.getCard(event.getTargetId()); + if (card != null) { + // Ethereal Valkyrie does not Foretell the card, it becomes Foretold, so don't add it to the Foretell list + foretoldCards.add(card.getId()); } } } - public boolean cardUsedForetell(UUID sourceId) { - return foretellCardsThisTurn.contains(sourceId); - } - public boolean cardWasForetold(UUID sourceId) { - return foretoldCardsThisTurn.contains(sourceId); + return foretoldCards.contains(sourceId); } public int countNumberForetellThisTurn() { return foretellCardsThisTurn.size(); } - public int countNumberForetoldThisTurn() { - return foretoldCardsThisTurn.size(); - } - @Override public void reset() { super.reset(); foretellCardsThisTurn.clear(); - foretoldCardsThisTurn.clear(); } }