mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 21:42:07 -08:00
- [KHC] Added Cosmic Intervention, Ethereal Valkyrie, Hero of Bretagard, and Ranar, the Ever-Watchful.
This commit is contained in:
parent
14f7c02b1f
commit
3b8e67c670
7 changed files with 816 additions and 6 deletions
|
|
@ -17,7 +17,7 @@ public enum ForetoldCondition implements Condition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
ForetoldWatcher watcher = game.getState().getWatcher(ForetoldWatcher.class);
|
||||
if (watcher != null) {
|
||||
return watcher.foretoldSpellWasCast(source.getSourceId());
|
||||
return watcher.cardWasForetold(source.getSourceId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -26,4 +26,4 @@ public enum ForetoldCondition implements Condition {
|
|||
public String toString() {
|
||||
return "this spell was foretold";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ 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.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
|
@ -21,9 +23,9 @@ import mage.watchers.Watcher;
|
|||
* @author jeffwadsworth
|
||||
*/
|
||||
public class ForetoldWatcher extends Watcher {
|
||||
|
||||
// If a card was Foretold during a 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> foretoldCardsThisTurn = new HashSet<>();
|
||||
|
||||
public ForetoldWatcher() {
|
||||
|
|
@ -32,10 +34,19 @@ 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 (card != null
|
||||
&& card.getAbilities(game).containsClass(ForetellAbility.class)
|
||||
&& controllerId == event.getPlayerId()) {
|
||||
foretellCardsThisTurn.add(card.getId());
|
||||
}
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST
|
||||
&& event.getZone() == Zone.EXILED) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell != null) {
|
||||
if (spell != null
|
||||
&& controllerId == event.getPlayerId()) {
|
||||
UUID exileId = CardUtil.getExileZoneId(spell.getSourceId().toString() + "foretellAbility", game);
|
||||
if (exileId != null) {
|
||||
foretoldCardsThisTurn.add(spell.getSourceId());
|
||||
|
|
@ -44,13 +55,26 @@ public class ForetoldWatcher extends Watcher {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean foretoldSpellWasCast(UUID sourceId) {
|
||||
public boolean cardUsedForetell(UUID sourceId) {
|
||||
return foretellCardsThisTurn.contains(sourceId);
|
||||
}
|
||||
|
||||
public boolean cardWasForetold(UUID sourceId) {
|
||||
return foretoldCardsThisTurn.contains(sourceId);
|
||||
}
|
||||
|
||||
public int countNumberForetellThisTurn() {
|
||||
return foretellCardsThisTurn.size();
|
||||
}
|
||||
|
||||
public int countNumberForetoldThisTurn() {
|
||||
return foretoldCardsThisTurn.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
foretellCardsThisTurn.clear();
|
||||
foretoldCardsThisTurn.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue