@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; }
@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; } }