- small refactor Foretell ability

This commit is contained in:
Jeff Wadsworth 2021-09-29 09:45:08 -05:00
parent 7d92ad45d9
commit 970125c5c4
3 changed files with 6 additions and 4 deletions

View file

@ -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;

View file

@ -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
}

View file

@ -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());