@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (abilityToModify instanceof SpellAbility) { Card sourceCard = game.getCard((abilityToModify).getSourceId()); if (sourceCard != null && (sourceCard.isInstant() || sourceCard.isSorcery())) { return true; } } return false; }
@Override public void init(Ability source, Game game) { super.init(source, game); if (this.affectedObjectsSet) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { player.getGraveyard().stream().map((cardId) -> game.getCard(cardId)).filter((card) -> (card.isInstant() || card.isSorcery())).forEachOrdered((card) -> { affectedObjectList.add(new MageObjectReference(card, game)); }); } } }
@Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (quickenWatcher.isQuickenSpellActive(affectedControllerId, source.getSourceId(), zoneChangeCounter)) { Card card = game.getCard(sourceId); if (card != null && card.isSorcery() && source.isControlledBy(affectedControllerId)) { return true; } } return false; }
@Override public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.MANA_PAID) { if (event.getData() != null && event.getData().equals(originalId)) { Card spell = game.getSpell(event.getTargetId()); if (spell != null && (spell.isInstant() || spell.isSorcery())) { spells.add(event.getTargetId()); } } } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if (((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD) { Card card = game.getCard(event.getTargetId()); if (card != null && (card.isSorcery() || card.isInstant())) { return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { boolean instantFound = false; boolean sorceryFound = false; Player player = game.getPlayer(source.getControllerId()); if (player != null) { for(Card card : player.getGraveyard().getCards(game)) { if (card.isInstant()) { if (sorceryFound) { return true; } instantFound = true; } else if (card.isSorcery()) { if (instantFound) { return true; } sorceryFound = true; } } } return false; } }
public SupportAbility(Card card, int amount) { super(new SupportEffect(card, amount, true)); if (!card.isInstant() && !card.isSorcery()) { FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures"); if (card.isCreature()) { filter.add(AnotherPredicate.instance); filter.setMessage("other target creatures"); } addTarget(new TargetCreaturePermanent(0, amount, filter, 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; }
public SupportEffect(Card card, int amount, boolean otherPermanent) { super(CounterType.P1P1.createInstance(0), new StaticValue(1)); this.amountSupportTargets = new StaticValue(amount); this.otherPermanent = otherPermanent; if (card.isInstant() || card.isSorcery()) { card.getSpellAbility().addTarget(new TargetCreaturePermanent(0, amount, new FilterCreaturePermanent("target creatures"), false)); } staticText = setText(); }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && controller.getLibrary().hasCards()) { Card card = controller.getLibrary().getFromTop(game); controller.moveCards(card, Zone.GRAVEYARD, source, game); if (card.isInstant() || card.isSorcery()) { new TransformSourceEffect(true).apply(game, source); } 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(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (!(source instanceof FlashbackAbility) && affectedControllerId.equals(source.getControllerId()) && game.isActivePlayer(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null && (card.isInstant() || card.isSorcery()) && game.getState().getZone(objectId).equals(Zone.GRAVEYARD)) { // check if not already a card was cast this turn with this ability KessDissidentMageWatcher watcher = game.getState().getWatcher(KessDissidentMageWatcher.class); return watcher != null && !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game)); } } return false; } }
@Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (affectedControllerId.equals(source.getControllerId())) { Card card = game.getCard(objectId); if (card != null) { Player controller = game.getPlayer(affectedControllerId); if (controller != null) { Card topCard = controller.getLibrary().getFromTop(game); MageObject precognitionField = game.getObject(source.getSourceId()); if (precognitionField != null && topCard != null) { return topCard == card && (topCard.isInstant() || topCard.isSorcery()) && topCard.getSpellAbility() != null && topCard.getSpellAbility().spellCanBeActivatedRegularlyNow(controller.getId(), game); } } } } return false; } }
private static int isRemoval(Card card) { if (card.isEnchantment() || card.isInstant() || card.isSorcery()) { for (Ability ability : card.getAbilities()) { for (Effect effect : ability.getEffects()) { if (isEffectRemoval(card, ability, effect) == 1) { return 1; } } for (Mode mode : ability.getModes().values()) { for (Effect effect : mode.getEffects()) { if (isEffectRemoval(card, ability, effect) == 1) { return 1; } } } } } return 0; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && controller.getLibrary().hasCards()) { Card card = controller.getLibrary().getFromTop(game); if (card != null) { switch (this.type) { case CREATURE: return card.isCreature(); case LAND: return card.isLand(); case SORCERY: return card.isSorcery(); case INSTANT: return card.isInstant(); } } } return false; } }
@Override public boolean applies(GameEvent event, Ability source, Game game) { if (Zone.GRAVEYARD == ((ZoneChangeEvent) event).getToZone()) { Card card = game.getCard(event.getSourceId()); if (card != null && (card.isInstant() || card.isSorcery())) { // TODO: Find a way to check, that the spell from graveyard was really cast by the ability of the emblem. // currently every spell cast from graveyard will be exiled. CastFromGraveyardWatcher watcher = game.getState().getWatcher(CastFromGraveyardWatcher.class); return watcher != null && watcher.spellWasCastFromGraveyard(event.getTargetId(), game.getState().getZoneChangeCounter(event.getTargetId())); } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card card = controller.getLibrary().getFromTop(game); if (card != null) { controller.lookAtCards(source, null, new CardsImpl(card), game); if (card.isInstant() || card.isSorcery()) { if (controller.chooseUse(Outcome.PlayForFree, "Cast " + card.getName() + " without paying its mana cost?", source, game)) { controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } } return true; } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isControlledBy(this.controllerId) && permanent.isCreature()) { MageObject object = game.getObject(event.getSourceId()); if (object instanceof Spell) { Card c = (Spell) object; if (c.isInstant() || c.isSorcery()) { if (getTargets().isEmpty()) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); } } return true; } } } return false; }
@Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isControlledBy(this.controllerId) && (permanent.hasSubtype(SubType.WOLF, game) || permanent.hasSubtype(SubType.WEREWOLF, game))) { MageObject object = game.getObject(event.getSourceId()); if (object instanceof Spell) { Card c = (Spell) object; if (c.isInstant() || c.isSorcery()) { if (getTargets().isEmpty()) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); } } return true; } } } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Library library = controller.getLibrary(); if (library.hasCards()) { Card card = library.getFromTop(game); if (card != null && controller.moveCardsToExile(card, source, game, true, source.getSourceId(), CardUtil.createObjectRealtedWindowTitle(source, game, null)) && (card.isInstant() || card.isSorcery())) { ContinuousEffect effect = new NivixAerieOfTheFiremindCanCastEffect(); effect.setTargetPointer(new FixedTarget(card.getId())); game.addEffect(effect, source); } } return true; } return false; } }