@Override public ExileTargetCost copy() { return new ExileTargetCost(this); }
public ExileTargetCost(TargetControlledPermanent target, boolean noText) { this.addTarget(target); }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Permanent permanent = source.getSourcePermanentIfItStillExists(game); if (player == null || permanent == null) { return false; } FilterControlledPermanent filter = new FilterControlledPermanent("tokens created with " + permanent.getName()); filter.add(new TetravusPredicate(new MageObjectReference(permanent, game))); filter.add(TokenPredicate.instance); ExileTargetCost cost = new ExileTargetCost(new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true)); if (cost.pay(source, game, source.getSourceId(), player.getId(), true)) { return new AddCountersSourceEffect(CounterType.P1P1.createInstance(cost.getPermanents().size())).apply(game, source); } return false; } }
@Override public boolean apply(Game game, Ability source) { ReturnFromGraveyardToBattlefieldTargetEffect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); if (!effect.apply(game, source)) { return false; } for (Cost c : source.getCosts()) { /* if (!c.getTargets().isEmpty()){ UUID t = c.getTargets().getFirstTarget(); Permanent exiled = game.getPermanentOrLKIBattlefield(t);*/ if (c.isPaid() && c instanceof ExileTargetCost) { for (Permanent exiled : ((ExileTargetCost) c).getPermanents()) { if (exiled != null) { if (exiled.hasSubtype(SubType.THRULL, game)) { game.getPermanent(source.getFirstTarget()).addCounters(CounterType.P2P2.createInstance(), source, game); return true; } } else { return false; } } } } return true; } }
@Override public Mana produceMana(boolean netMana, Game game, Ability source) { if (netMana) { return null; } Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int manaCostExiled = 0; for (Cost cost : source.getCosts()) { if (cost.isPaid() && cost instanceof ExileTargetCost) { for (Card card : ((ExileTargetCost) cost).getPermanents()) { manaCostExiled += card.getConvertedManaCost(); } } } ChoiceColor choice = new ChoiceColor(); if (!controller.choose(Outcome.PutManaInPool, choice, game)) { return null; } Mana chosen = choice.getMana(manaCostExiled + 1); return manaBuilder.setMana(chosen, source, game).build(); } return null; }
public FoodChain(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); // Exile a creature you control: Add X mana of any one color, where X is the exiled creature's converted mana cost plus one. Spend this mana only to cast creature spells. Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, new FoodChainManaEffect(), new ExileTargetCost(new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_A_CREATURE, true))); this.addAbility(ability); }
public ExileTargetCost(TargetControlledPermanent target) { this.addTarget(target); this.text = "Exile " + target.getTargetName(); }
public SoulExchange(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}{B}"); // As an additional cost to cast Soul Exchange, exile a creature you control. Cost cost = new ExileTargetCost(new TargetControlledCreaturePermanent()); this.getSpellAbility().addCost(cost); // Return target creature card from your graveyard to the battlefield. Put a +2/+2 counter on that creature if the exiled creature was a Thrull. this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); this.getSpellAbility().addEffect(new SoulExchangeEffect()); }
public CityOfShadows(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.LAND},""); // {T}, Exile a creature you control: Put a storage counter on City of Shadows. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.STORAGE.createInstance()), new TapSourceCost()); ability.addCost(new ExileTargetCost(new TargetControlledCreaturePermanent())); this.addAbility(ability); // {T}: Add X mana of {C}, where X is the number of storage counters on City of Shadows. ability = new DynamicManaAbility(Mana.ColorlessMana(1), new CountersSourceCount(CounterType.STORAGE), "Add X mana of {C}, where X is the number of storage counters on {this}"); this.addAbility(ability); }