@Override public ExileFromHandCost copy() { return new ExileFromHandCost(this); }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { for (Cost cost : sourceAbility.getCosts()) { if (cost.isPaid() && cost instanceof ExileFromHandCost) { int xValue = 0; for (Card card : ((ExileFromHandCost) cost).getCards()) { xValue += card.getConvertedManaCost(); } return xValue; } } return sourceAbility.getManaCostsToPay().getX(); }
/** * * @param target * @param setXFromCMC the spells X value on the stack is set to the * converted mana costs of the exiled card */ public ExileFromHandCost(TargetCardInHand target, boolean setXFromCMC) { this.addTarget(target); this.text = "exile " + target.getTargetName(); this.setXFromCMC = setXFromCMC; }
public Sunscour(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{W}{W}"); // You may exile two white cards from your hand rather than pay Sunscour's mana cost. this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(2, filter)))); // Destroy all creatures. this.getSpellAbility().addEffect(new DestroyAllEffect(StaticFilters.FILTER_PERMANENT_CREATURES)); }
@Override public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getFirstTarget()); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { for (Cost cost : source.getCosts()) { if (cost instanceof ExileFromHandCost) { List<CardType> cardtypes = new ArrayList<>(); ExileFromHandCost exileCost = (ExileFromHandCost) cost; for (CardType cardtype : exileCost.getCards().get(0).getCardType()) { cardtypes.add(cardtype); } for (CardType cardtype : card.getCardType()) { if (cardtypes.contains(cardtype)) { Effect effect = new ReturnToHandTargetEffect(); effect.setTargetPointer(new FixedTarget(card.getId())); return effect.apply(game, source); } } } } } return false; } }
public CadaverousBloom(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{B}{G}"); // Exile a card from your hand: Add {B}{B} or {G}{G}. this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.BlackMana(2), new ExileFromHandCost(new TargetCardInHand(new FilterOwnedCard("a card from your hand"))))); this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.GreenMana(2), new ExileFromHandCost(new TargetCardInHand(new FilterOwnedCard("a card from your hand"))))); }
private boolean isConvertedManaCostEqual(Ability sourceAbility, int amount) { for (Cost cost : sourceAbility.getCosts()) { if (cost.isPaid() && cost instanceof ExileFromHandCost) { for (Card card : ((ExileFromHandCost) cost).getCards()) { if (card instanceof SplitCard) { if (((SplitCard) card).getLeftHalfCard().getConvertedManaCost() == amount) { return true; } if (((SplitCard) card).getRightHalfCard().getConvertedManaCost() == amount) { return true; } } else if (card.getConvertedManaCost() == amount) { return true; } } return false; } } // No alternate costs payed so compare to X value return sourceAbility.getManaCostsToPay().getX() == amount; }
public Commandeer(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{5}{U}{U}"); // You may exile two blue cards from your hand rather than pay Commandeer's mana cost. this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(2, filter)))); // Gain control of target noncreature spell. You may choose new targets for it. this.getSpellAbility().addEffect(new CommandeerEffect()); this.getSpellAbility().addTarget(new TargetSpell(filterSpell)); }
for (Cost cost : source.getCosts()) { if (cost instanceof ExileFromHandCost) { cards = ((ExileFromHandCost) cost).getCards();
public Unmask(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}"); // You may exile a black card from your hand rather than pay Unmask's mana cost. this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // Target player reveals their hand. You choose a nonland card from it. That player discards that card. this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addEffect(new DiscardCardYouChooseTargetEffect(filterNonLand, TargetController.ANY)); }
public ForsakenCity(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.LAND},""); // Forsaken City doesn't untap during your untap step. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DontUntapInControllersUntapStepSourceEffect())); // At the beginning of your upkeep, you may exile a card from your hand. If you do, untap Forsaken City. this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DoIfCostPaid(new UntapSourceEffect(), new ExileFromHandCost(new TargetCardInHand(filter))), TargetController.YOU, true)); // {T}: Add one mana of any color. this.addAbility(new AnyColorManaAbility()); }
public SoulSpike(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{5}{B}{B}"); // You may exile two black cards from your hand rather than pay Soul Spike's mana cost. this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(2, filter)))); // Soul Spike deals 4 damage to any target and you gain 4 life. this.getSpellAbility().addTarget(new TargetAnyTarget()); this.getSpellAbility().addEffect(new DamageTargetEffect(4)); this.getSpellAbility().addEffect(new GainLifeEffect(4)); }
public FuryOfTheHorde(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{5}{R}{R}"); // You may exile two red cards from your hand rather than pay Fury of the Horde's mana cost. this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(2, filter)))); // Untap all creatures that attacked this turn. After this main phase, there is an additional combat phase followed by an additional main phase. this.getSpellAbility().addEffect(new UntapAllThatAttackedEffect()); this.getSpellAbility().addEffect(new AddCombatAndMainPhaseEffect()); this.getSpellAbility().addWatcher(new AttackedThisTurnWatcher()); }
public NourishingShoal(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{G}{G}"); this.subtype.add(SubType.ARCANE); // You may exile a green card with converted mana cost X from your hand rather than pay Nourishing Shoal's mana cost. FilterOwnedCard filter = new FilterOwnedCard("a green card with converted mana cost X from your hand"); filter.add(new ColorPredicate(ObjectColor.GREEN)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true))); // You gain X life. this.getSpellAbility().addEffect(new GainLifeEffect(ExileFromHandCostCardConvertedMana.instance)); }
public CaveIn(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{R}{R}"); // You may exile a red card from your hand rather than pay Cave-In's mana cost. FilterOwnedCard filter = new FilterOwnedCard("a red card from your hand"); filter.add(new ColorPredicate(ObjectColor.RED)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // Cave-In deals 2 damage to each creature and each player. this.getSpellAbility().addEffect(new DamageEverythingEffect(2)); }
public Snapback(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}"); // You may exile a blue card from your hand rather than pay Snapback's mana cost. FilterOwnedCard filterCardInHand = new FilterOwnedCard("a blue card from your hand"); filterCardInHand.add(new ColorPredicate(ObjectColor.BLUE)); filterCardInHand.add(Predicates.not(new CardIdPredicate(this.getId()))); this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filterCardInHand)))); // Return target creature to its owner's hand. this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); }
public ReverentMantra(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{W}"); // You may exile a white card from your hand rather than pay Reverent Mantra's mana cost. FilterOwnedCard filter = new FilterOwnedCard("a white card from your hand"); filter.add(new ColorPredicate(ObjectColor.WHITE)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // Choose a color. All creatures gain protection from the chosen color until end of turn. this.getSpellAbility().addEffect(new GainProtectionFromColorAllEffect(Duration.EndOfTurn, new FilterCreaturePermanent())); }
public BountyOfTheHunt(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{G}{G}"); // You may exile a green card from your hand rather than pay Bounty of the Hunt's mana cost. FilterOwnedCard filter = new FilterOwnedCard("green card from your hand"); filter.add(new ColorPredicate(ObjectColor.GREEN)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // Distribute three +1/+1 counters among one, two, or three target creatures. For each +1/+1 counter you put on a creature this way, remove a +1/+1 counter from that creature at the beginning of the next cleanup step. this.getSpellAbility().addEffect(new DistributeCountersEffect(CounterType.P1P1, 3, true, "one, two, or three target creatures")); this.getSpellAbility().addTarget(new TargetCreaturePermanentAmount(3)); }
public Misdirection(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{U}{U}"); // You may exile a blue card from your hand rather than pay Misdirection's mana cost. FilterOwnedCard filterCardInHand = new FilterOwnedCard("a blue card from your hand"); filterCardInHand.add(new ColorPredicate(ObjectColor.BLUE)); // the exile cost can never be paid with the card itself filterCardInHand.add(Predicates.not(new CardIdPredicate(this.getId()))); this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filterCardInHand)))); // Change the target of target spell with a single target. this.getSpellAbility().addEffect(new ChooseNewTargetsTargetEffect(true, true)); this.getSpellAbility().addTarget(new TargetSpell(filter2)); }
public Pyrokinesis(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{4}{R}{R}"); // You may exile a red card from your hand rather than pay Pyrokinesis's mana cost. FilterOwnedCard filter = new FilterOwnedCard("a red card from your hand"); filter.add(new ColorPredicate(ObjectColor.RED)); filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter)))); // Pyrokinesis deals 4 damage divided as you choose among any number of target creatures. this.getSpellAbility().addEffect(new DamageMultiEffect(4)); this.getSpellAbility().addTarget(new TargetCreaturePermanentAmount(4)); }