From 970125c5c4b07f438db9a9d66424d0dc785080a8 Mon Sep 17 00:00:00 2001 From: Jeff Wadsworth Date: Wed, 29 Sep 2021 09:45:08 -0500 Subject: [PATCH] - small refactor Foretell ability --- .../main/java/mage/abilities/keyword/ForetellAbility.java | 2 ++ Mage/src/main/java/mage/game/events/GameEvent.java | 1 + .../main/java/mage/watchers/common/ForetoldWatcher.java | 7 +++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java index 6bcf3bf45e..045cfd7085 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ForetellAbility.java @@ -24,6 +24,7 @@ import mage.util.CardUtil; import mage.watchers.common.ForetoldWatcher; import java.util.UUID; +import mage.game.events.GameEvent; /** * @author jeffwadsworth @@ -142,6 +143,7 @@ public class ForetellAbility extends SpecialAction { effect.apply(game, source); card.setFaceDown(true, game); game.addEffect(new ForetellAddCostEffect(new MageObjectReference(card, game)), source); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.FORETELL, card.getId(), null, source.getControllerId())); return true; } return false; diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index bad2b18743..69c5415482 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -465,6 +465,7 @@ public class GameEvent implements Serializable { DUNGEON_COMPLETED, REMOVED_FROM_COMBAT, // targetId id of permanent removed from combat FORETOLD, // targetId id of card foretold + FORETELL, // targetId id of card foretell playerId id of the controller //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 f62a879d05..3213e8b76d 100644 --- a/Mage/src/main/java/mage/watchers/common/ForetoldWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/ForetoldWatcher.java @@ -3,11 +3,11 @@ package mage.watchers.common; import java.util.HashSet; import java.util.Set; import java.util.UUID; -import mage.abilities.keyword.ForetellAbility; import mage.cards.Card; import mage.constants.WatcherScope; import mage.game.Game; import mage.game.events.GameEvent; +import mage.util.CardUtil; import mage.watchers.Watcher; /** @@ -26,10 +26,9 @@ public class ForetoldWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.TAKEN_SPECIAL_ACTION) { - Card card = game.getCard(event.getSourceId()); + if (event.getType() == GameEvent.EventType.FORETELL) { + Card card = game.getCard(event.getTargetId()); if (card != null - && card.getAbilities(game).containsClass(ForetellAbility.class) && controllerId == event.getPlayerId()) { foretellCardsThisTurn.add(card.getId()); foretoldCards.add(card.getId());