@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Card target = (Card) game.getObject(source.getFirstTarget()); if (controller != null && target != null) { return controller.cast(target.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } return false; }
@Override public boolean apply(Game game, Ability source) { Card card = (Card) game.getObject(source.getSourceId()); if (card != null) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { SpellAbility spellAbility = card.getSpellAbility(); spellAbility.clear(); return controller.cast(spellAbility, game, true, new MageObjectReference(source.getSourceObject(game), game)); } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Card card = game.getCard(source.getFirstTarget()); if (controller == null || card == null) { return false; } controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); game.addEffect(new WrexialReplacementEffect(card.getId()), source); return true; } }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { Player player = game.getPlayer(source.getControllerId()); if (player != null && player.chooseUse(Outcome.Benefit, "Cast " + card.getName() + " without paying cost?", source, game)) { player.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Card sourceCard = game.getCard(source.getSourceId()); if (controller != null && sourceCard != null && Zone.GRAVEYARD == game.getState().getZone(sourceCard.getId())) { controller.cast(sourceCard.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Card cipherCard = game.getCard(cipherCardId); if (cipherCard != null && controller != null) { Card copyCard = game.copyCard(cipherCard, source, controller.getId()); SpellAbility ability = copyCard.getSpellAbility(); // remove the cipher effect from the copy ability.getEffects().removeIf(effect -> effect instanceof CipherEffect); controller.cast(ability, game, true, new MageObjectReference(source.getSourceObject(game), game)); } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { controller.cast(card.getSpellAbility(), game, false, new MageObjectReference(source.getSourceObject(game), game)); game.addEffect(new ToshiroUmezawaReplacementEffect(card.getId()), source); } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { Card card = player.getLibrary().getFromTop(game); if (card != null) { player.moveCards(card, Zone.EXILED, source, game); if (card.isLand()) { player.moveCards(card, Zone.BATTLEFIELD, source, game); } else { player.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card card = controller.getGraveyard().get(getTargetPointer().getFirst(game, source), game); if (card != null) { if (controller.chooseUse(outcome, "Cast " + card.getIdName() + " from your graveyard?", source, game)) { controller.cast(card.getSpellAbility(), game, false, new MageObjectReference(source.getSourceObject(game), game)); } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); // use target pointer here, so it's the same card that triggered the event (not gone back to library e.g.) Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (controller != null && card != null) { SpellAbility abilityToCast = card.getSpellAbility().copy(); ManaCosts<ManaCost> costRef = abilityToCast.getManaCostsToPay(); // replace with the new cost costRef.clear(); costRef.add(miracleCosts); controller.cast(abilityToCast, game, false, new MageObjectReference(source.getSourceObject(game), game)); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { ExileZone zone = game.getExile().getExileZone(source.getSourceId()); if (zone == null || zone.isEmpty()) { return false; } Card reboundCard = zone.get(source.getSourceId(), game); Player player = game.getPlayer(source.getControllerId()); if (player != null && reboundCard != null) { SpellAbility ability = reboundCard.getSpellAbility(); player.cast(ability, game, true, new MageObjectReference(source.getSourceObject(game), game)); zone.remove(reboundCard.getId()); return true; } 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 apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { if (controller.moveCards(card, Zone.EXILED, source, game)) { Card cardCopy = game.copyCard(card, source, source.getControllerId()); if (cardCopy.getSpellAbility().canChooseTarget(game) && controller.chooseUse(outcome, "Cast copy of " + card.getName() + " without paying its mana cost?", source, game)) { controller.cast(cardCopy.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { FilterCard filter = new FilterInstantOrSorceryCard(); int cardsToCast = controller.getHand().count(filter, source.getControllerId(), source.getSourceId(), game); if (cardsToCast > 0 && controller.chooseUse(outcome, "Cast an instant or sorcery card from your hand without paying its mana cost?", source, game)) { TargetCardInHand target = new TargetCardInHand(filter); controller.chooseTarget(outcome, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player == null || !player.getLibrary().hasCards()) { return false; } Card card = player.getLibrary().getFromTop(game); if (card == null) { return false; } player.revealCards(source, new CardsImpl(card), game); if (card.getConvertedManaCost() % 2 == 1) { if (player.chooseUse(outcome, "Cast " + card.getLogName() + " without paying its mana cost?", source, game)) { player.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } else { player.drawCards(1, game); } return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetCardInExile target = new TargetCardInExile(new FilterCard(), CardUtil.getCardExileZoneId(game, source)); if (controller.choose(Outcome.PlayForFree, game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)), target, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { game.getExile().removeCard(card, game); return controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (controller != null && opponent != null) { TargetCardInLibrary target = new TargetCardInLibrary(0, 1, new FilterInstantOrSorceryCard()); if (controller.searchLibrary(target, game, opponent.getId())) { Card card = opponent.getLibrary().remove(target.getFirstTarget(), game); if (card != null) { controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } opponent.shuffleLibrary(source, game); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); if (opponent != null && controller != null) { Cards cardsInHand = new CardsImpl(); cardsInHand.addAll(opponent.getHand()); if (!cardsInHand.isEmpty()) { TargetCard target = new TargetCard(1, Zone.HAND, new FilterNonlandCard()); if (controller.chooseTarget(outcome, cardsInHand, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); if (card != null) { if (controller.chooseUse(outcome, "Cast " + card.getLogName() + '?', source, game)) { if (controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game))) { ContinuousEffect effect = new GoblinDarkDwellersReplacementEffect(card.getId()); effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId()))); game.addEffect(effect, source); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { FilterCard filter = new FilterCard(); filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, source.getManaCostsToPay().getX())); TargetCardInExile target = new TargetCardInExile(filter, CardUtil.getCardExileZoneId(game, source)); Cards cards = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); if (!cards.isEmpty() && controller.choose(Outcome.PlayForFree, cards, target, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } return true; } return false; } }