@Override public String getIdName() { String idName; if (card != null) { idName = card.getId().toString().substring(0, 3); } else { idName = getId().toString().substring(0, 3); } return getName() + " [" + idName + ']'; }
@Override public StackObject createCopyOnStack(Game game, Ability source, UUID newControllerId, boolean chooseNewTargets) { Spell copy = this.copySpell(newControllerId); game.getState().setZone(copy.getId(), Zone.STACK); // required for targeting ex: Nivmagus Elemental game.getStack().push(copy); if (chooseNewTargets) { copy.chooseNewTargets(game, newControllerId); } game.fireEvent(new GameEvent(EventType.COPIED_STACKOBJECT, copy.getId(), this.getId(), newControllerId)); return copy; }
@Override public void watch(GameEvent event, Game game) { switch (event.getType()) { case SPELL_CAST: case CAST_SPELL: Spell spell = (Spell) game.getObject(event.getTargetId()); if (spell != null && !playerFirstSpellCast.containsKey(spell.getControllerId())) { if (event.getType() == EventType.SPELL_CAST) { playerFirstSpellCast.put(spell.getControllerId(), spell.getId()); } else if (event.getType() == EventType.CAST_SPELL) { playerFirstCastSpell.put(spell.getControllerId(), spell.getId()); } } } }
@Override public boolean apply(Game game, Ability source) { List<Spell> spellsToCounter = new LinkedList<>(); for (StackObject stackObject : game.getStack()) { if (stackObject instanceof Spell && !stackObject.isControlledBy(source.getControllerId())) { spellsToCounter.add((Spell) stackObject); } } for (Spell spell : spellsToCounter) { game.getStack().counter(spell.getId(), source.getSourceId(), game); } return true; }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST) { if (isSavageSummoningSpellActive() && event.getPlayerId().equals(getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.isCreature()) { spellsCastWithSavageSummoning.put(spell.getId(), new HashSet<>(savageSummoningSpells)); String cardKey = spell.getCard().getId().toString() + '_' + spell.getCard().getZoneChangeCounter(game); cardsCastWithSavageSummoning.put(cardKey, new HashSet<>(savageSummoningSpells)); savageSummoningSpells.clear(); } } } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.isEnchantment()) { firstEnchantmentThisTurn.putIfAbsent( event.getPlayerId(), spell.getId() ); } } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST && ready) { if (uncounterableSpell == null && event.getPlayerId().equals(this.getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && (spell.isCreature())) { uncounterableSpell = spell.getId(); ready = false; } } } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST && ready) { if (uncounterableSpell == null && event.getPlayerId().equals(this.getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && (spell.isSorcery() || spell.isInstant())) { uncounterableSpell = spell.getId(); ready = false; } } } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == GameEvent.EventType.COUNTER) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && watcher.isSpellCastWithThisSavageSummoning(spell.getId(), source.getSourceId(), zoneChangeCounter)) { return true; } } return false; }
@Override public boolean applies(GameEvent event, Ability source, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); OvermasterWatcher watcher = game.getState().getWatcher(OvermasterWatcher.class, source.getControllerId()); return spell != null && watcher != null && watcher.isUncounterable(spell.getId()); } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { BoseijuWhoSheltersAllWatcher watcher = game.getState().getWatcher(BoseijuWhoSheltersAllWatcher.class, source.getSourceId()); Spell spell = game.getStack().getSpell(event.getTargetId()); return spell != null && watcher != null && watcher.spellCantBeCountered(spell.getId()); } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); InsistWatcher watcher = game.getState().getWatcher(InsistWatcher.class, source.getControllerId()); return spell != null && watcher != null && watcher.isUncounterable(spell.getId()); } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { CavernOfSoulsWatcher watcher = game.getState().getWatcher(CavernOfSoulsWatcher.class, source.getSourceId()); Spell spell = game.getStack().getSpell(event.getTargetId()); return spell != null && watcher != null && watcher.spellCantBeCountered(spell.getId()); } }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && filter.match(spell, game)) { if (rememberSource) { this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId())); } return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); if (spell != null && controller != null) { Spell copy = spell.copySpell(source.getControllerId()); copy.getColor(game).setRed(true); game.getStack().push(copy); copy.chooseNewTargets(game, controller.getId()); game.fireEvent(new GameEvent(GameEvent.EventType.COPIED_STACKOBJECT, copy.getId(), spell.getId(), source.getControllerId())); return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) { if (rememberSource) { this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId())); } return true; } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && (spell.isInstant() || spell.isSorcery())) { for (Effect effect : getEffects()) { if (effect instanceof HiveMindEffect) { effect.setTargetPointer(new FixedTarget(spell.getId())); } } return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getCard() != null && !spell.getCard().isCopy()) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(spell.getId())); } return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (isControlledInstantOrSorcery(spell)) { Permanent permanent = game.getBattlefield().getPermanent(this.getSourceId()); if (permanent != null && permanent.getCounters(game).getCount(CounterType.QUEST) >= 2) { this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId())); return true; } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && (spell.isInstant() || spell.isSorcery())) { Permanent enchantment = game.getPermanent(sourceId); if (enchantment != null && enchantment.getAttachedTo() != null) { Player player = game.getPlayer(enchantment.getAttachedTo()); if (player != null && spell.isControlledBy(player.getId())) { this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId())); return true; } } } return false; }