@Override public boolean apply(MageObject input, Game game) { if (input instanceof Spell) { if (((Spell) input).getFromZone() == Zone.GRAVEYARD) { return true; } } return false; } }
@Override public boolean apply(StackObject input, Game game) { return input instanceof Spell && ((Spell) input).getFromZone().match(zone); }
@Override public boolean apply(Game game, Ability source) { MageObject object = game.getObject(source.getSourceId()); if (object instanceof Spell && ((Spell) object).getFromZone() == Zone.GRAVEYARD) { for (Ability ability : ((Spell) object).getAbilities(game)) { if (ability instanceof FlashbackAbility) { return true; } } } return false; } }
@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify.getSourceId().equals(source.getSourceId())) { Spell spell = game.getStack().getSpell(abilityToModify.getSourceId()); return spell != null && spell.getFromZone() == Zone.GRAVEYARD; } return false; }
@Override public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell == null || spell.getFromZone() != Zone.HAND) { return false; } return new AddManaOfAnyColorEffect(10).apply(game, source); } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if (((ZoneChangeEvent) event).getFromZone() == Zone.STACK && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD && event.getSourceId() != null && event.getSourceId().equals(source.getSourceId())) { // if countered the source.sourceId is different or null if it fizzles Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getFromZone() == Zone.HAND) { return true; } } return false; }
boolean isCastFromPlayersLibrary(Game game, UUID playerId) { if (!game.getStack().isEmpty()) { StackObject stackObject = game.getStack().getLast(); return stackObject instanceof Spell && !((Spell) stackObject).isDoneActivatingManaAbilities() && Zone.LIBRARY.equals(((Spell) stackObject).getFromZone()); } return false; }
@Override public boolean apply(Game game, Ability source) { int amount = 5; Spell spell = (Spell) game.getStack().getStackObject(source.getSourceId()); if (spell != null) { if (spell.getFromZone() == Zone.GRAVEYARD) { amount = 10; } token.putOntoBattlefield(amount, game, source.getSourceId(), source.getControllerId()); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { int amount = 5; Spell spell = (Spell) game.getStack().getStackObject(source.getSourceId()); if (spell != null) { if (spell.getFromZone() == Zone.GRAVEYARD) { amount = 10; } Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if (permanent != null) { permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getFromZone() == Zone.HAND && spell.isOwnedBy(getControllerId())) { // must be from the controller's hand if (spell.getCard() != null) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(spell.getId())); } return true; } } } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (StackObject stackObject : game.getStack()) { // only spells cast, so no copies of spells if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.isControlledBy(source.getControllerId())) { Spell spell = (Spell) stackObject; if (spell.getFromZone() == Zone.HAND) { game.getState().addOtherAbility(spell.getCard(), cascadeAbility); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); if (spell != null) { StackObject stackObjectCopy = spell.createCopyOnStack(game, source, source.getControllerId(), true); if (stackObjectCopy instanceof Spell) { game.informPlayers(controller.getLogName() + ((Spell) stackObjectCopy).getActivatedMessage(game)); } Spell sourceSpell = (Spell) game.getStack().getStackObject(source.getSourceId()); if (sourceSpell != null) { if (sourceSpell.getFromZone() == Zone.GRAVEYARD) { stackObjectCopy = spell.createCopyOnStack(game, source, source.getControllerId(), true); if (stackObjectCopy instanceof Spell) { game.informPlayers(new StringBuilder(controller.getLogName()).append(((Spell) stackObjectCopy).getActivatedMessage(game)).toString()); } } } 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 && spell.getFromZone() == Zone.HAND) { if (spell.getCard() != null && spell.getCard().isInstant() || spell.getCard().isSorcery()) { for (Effect effect : 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 (spell != null && spell.getFromZone() == Zone.HAND) { if (spell.getCard() != null && spell.getCard().isInstant() || spell.getCard().isSorcery()) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(spell.getId())); } return true; } } } return false; }
@Override public boolean applies(GameEvent evt, Ability source, Game game) { ZoneChangeEvent event = (ZoneChangeEvent) evt; if (event.getFromZone() == Zone.STACK && event.getToZone() != Zone.EXILED) { // Moving something from stack to somewhere else // Get the source id, getting the whole split card's ID, because // that's the card that is changing zones in the event, but // source.getSourceId is only the split card half. // If branch so that we also support putting Aftermath on // non-split cards for... whatever reason, in case somebody // wants to do that in the future. UUID sourceId = source.getSourceId(); Card sourceCard = game.getCard(source.getSourceId()); if (sourceCard instanceof SplitCardHalf) { sourceCard = ((SplitCardHalf) sourceCard).getParentCard(); sourceId = sourceCard.getId(); } if (event.getTargetId().equals(sourceId)) { // Moving this spell from stack to yard Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null && spell.getFromZone() == Zone.GRAVEYARD) { // And this spell was cast from the graveyard, so we need to exile it return true; } } } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); if (player != null) { int amount = source.getManaCostsToPay().getX(); Spell spell = (Spell) game.getStack().getStackObject(source.getSourceId()); if (spell != null) { if (spell.getFromZone() == Zone.GRAVEYARD) { amount *= 2; } player.moveCards(player.getLibrary().getTopCards(game, amount), Zone.GRAVEYARD, source, game); return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { MageObject object = game.getObject(source.getSourceId()); if (object instanceof SplitCardHalf) { UUID splitCardId = ((Card) object).getMainCard().getId(); object = game.getObject(splitCardId); } if (object instanceof Spell) { // needed to check if it can be cast by alternate cost Spell spell = (Spell) object; return spell.getFromZone() == Zone.HAND; } if (object instanceof Card) { // needed for the check what's playable Card card = (Card) object; return game.getPlayer(card.getOwnerId()).getHand().get(card.getId(), game) != null; } return false; } }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.PLAY_LAND) { fromZone = game.getState().getZone(event.getTargetId()); // Remember the Zone the land came from } if (event.getType() == GameEvent.EventType.LAND_PLAYED && fromZone == Zone.GRAVEYARD) { addPermanentTypes(event, game.getPermanentOrLKIBattlefield(event.getTargetId()), game); } if (event.getType() == GameEvent.EventType.SPELL_CAST) { Spell spell = (Spell) game.getObject(event.getTargetId()); if (spell.getFromZone() == Zone.GRAVEYARD) { addPermanentTypes(event, spell, game); } } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { Spell spell = (Spell) game.getStack().getStackObject(source.getSourceId()); if (spell != null) { if (spell.getFromZone() == Zone.GRAVEYARD) { target = new TargetCardInLibrary(2, new FilterCard()); } else { target = new TargetCardInLibrary(); } if (player.searchLibrary(target, game)) { if (!target.getTargets().isEmpty()) { for (UUID cardId: target.getTargets()) { Card card = player.getLibrary().remove(cardId, game); if (card != null) { card.moveToZone(Zone.HAND, source.getSourceId(), game, false); } } } } // shuffle anyway player.shuffleLibrary(source, game); return true; } } return false; }
&& !spell.isCopy() && watcher.getApproachesCast(controller.getId()) > 1 && spell.getFromZone() == Zone.HAND) {