mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
- Fixed #8334. Refactored and simplified some aspects of the Foretell ability.
This commit is contained in:
parent
b37dd094e1
commit
6f76c3371e
4 changed files with 14 additions and 23 deletions
|
|
@ -177,6 +177,7 @@ class EtherealValkyrieEffect extends OneShotEffect {
|
||||||
foretellAbility.activate(game, true);
|
foretellAbility.activate(game, true);
|
||||||
ContinuousEffect effect = foretellAbility.new ForetellAddCostEffect(new MageObjectReference(exileCard, game));
|
ContinuousEffect effect = foretellAbility.new ForetellAddCostEffect(new MageObjectReference(exileCard, game));
|
||||||
game.addEffect(effect, source);
|
game.addEffect(effect, source);
|
||||||
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.FORETOLD, exileCard.getId(), null, null));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,10 @@ public class ForetellAbility extends SpecialAction {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null
|
if (controller != null
|
||||||
&& card != null) {
|
&& card != null) {
|
||||||
|
|
||||||
|
// get main card id
|
||||||
UUID mainCardId = card.getMainCard().getId();
|
UUID mainCardId = card.getMainCard().getId();
|
||||||
|
|
||||||
// retrieve the exileId of the foretold card
|
// retrieve the exileId of the foretold card
|
||||||
UUID exileId = CardUtil.getExileZoneId(mainCardId.toString() + "foretellAbility", game);
|
UUID exileId = CardUtil.getExileZoneId(mainCardId.toString() + "foretellAbility", game);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -464,6 +464,7 @@ public class GameEvent implements Serializable {
|
||||||
VENTURE, VENTURED,
|
VENTURE, VENTURED,
|
||||||
DUNGEON_COMPLETED,
|
DUNGEON_COMPLETED,
|
||||||
REMOVED_FROM_COMBAT, // targetId id of permanent removed from combat
|
REMOVED_FROM_COMBAT, // targetId id of permanent removed from combat
|
||||||
|
FORETOLD, // targetId id of card foretold
|
||||||
//custom events
|
//custom events
|
||||||
CUSTOM_EVENT
|
CUSTOM_EVENT
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,8 @@ import java.util.UUID;
|
||||||
import mage.abilities.keyword.ForetellAbility;
|
import mage.abilities.keyword.ForetellAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.WatcherScope;
|
import mage.constants.WatcherScope;
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.stack.Spell;
|
|
||||||
import mage.util.CardUtil;
|
|
||||||
import mage.watchers.Watcher;
|
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.
|
// 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<UUID> foretellCardsThisTurn = new HashSet<>();
|
private final Set<UUID> foretellCardsThisTurn = new HashSet<>();
|
||||||
private final Set<UUID> foretoldCardsThisTurn = new HashSet<>();
|
private final Set<UUID> foretoldCards = new HashSet<>();
|
||||||
|
|
||||||
public ForetoldWatcher() {
|
public ForetoldWatcher() {
|
||||||
super(WatcherScope.GAME);
|
super(WatcherScope.GAME);
|
||||||
|
|
@ -35,41 +32,30 @@ public class ForetoldWatcher extends Watcher {
|
||||||
&& card.getAbilities(game).containsClass(ForetellAbility.class)
|
&& card.getAbilities(game).containsClass(ForetellAbility.class)
|
||||||
&& controllerId == event.getPlayerId()) {
|
&& controllerId == event.getPlayerId()) {
|
||||||
foretellCardsThisTurn.add(card.getId());
|
foretellCardsThisTurn.add(card.getId());
|
||||||
|
foretoldCards.add(card.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.getType() == GameEvent.EventType.SPELL_CAST
|
// Ethereal Valkyrie
|
||||||
&& event.getZone() == Zone.EXILED) {
|
if (event.getType() == GameEvent.EventType.FORETOLD) {
|
||||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
Card card = game.getCard(event.getTargetId());
|
||||||
if (spell != null
|
if (card != null) {
|
||||||
&& controllerId == event.getPlayerId()) {
|
// Ethereal Valkyrie does not Foretell the card, it becomes Foretold, so don't add it to the Foretell list
|
||||||
UUID exileId = CardUtil.getExileZoneId(spell.getSourceId().toString() + "foretellAbility", game);
|
foretoldCards.add(card.getId());
|
||||||
if (exileId != null) {
|
|
||||||
foretoldCardsThisTurn.add(spell.getSourceId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cardUsedForetell(UUID sourceId) {
|
|
||||||
return foretellCardsThisTurn.contains(sourceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean cardWasForetold(UUID sourceId) {
|
public boolean cardWasForetold(UUID sourceId) {
|
||||||
return foretoldCardsThisTurn.contains(sourceId);
|
return foretoldCards.contains(sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int countNumberForetellThisTurn() {
|
public int countNumberForetellThisTurn() {
|
||||||
return foretellCardsThisTurn.size();
|
return foretellCardsThisTurn.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int countNumberForetoldThisTurn() {
|
|
||||||
return foretoldCardsThisTurn.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
super.reset();
|
super.reset();
|
||||||
foretellCardsThisTurn.clear();
|
foretellCardsThisTurn.clear();
|
||||||
foretoldCardsThisTurn.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue