mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
- small refactor Foretell ability
This commit is contained in:
parent
7d92ad45d9
commit
970125c5c4
3 changed files with 6 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue