@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Permanent sourcePermanent = game.getBattlefield().getPermanent(sourceId); if (sourcePermanent != null) { Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo()); if (attachedTo != null) { paid = attachedTo.getManaCost().pay(ability, game, sourceId, controllerId, noMana); } } return paid; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + '?', source, game)) { cost.clearPaid(); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)){ return true; } } player.lost(game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}"); int xValue = controller.announceXMana(0, Integer.MAX_VALUE, "Choose the amount of mana to pay", game, source); cost.add(new GenericManaCost(xValue)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false) && xValue > 0) { new RevealLibraryPutIntoHandEffect(xValue, filter, Zone.LIBRARY, false).apply(game, source); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}"); if (you != null && you.chooseUse(Outcome.Neutral, "Do you want to to pay {X}?", source, game)) { int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { Token token = new GoblinSoldierToken(); return token.putOntoBattlefield(costX, game, source.getSourceId(), source.getControllerId()); } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { ManaCosts cost = new ManaCostsImpl("{X}{W}{U}{U}"); if (controller.chooseUse(Outcome.Damage, "Pay " + cost.getText() + "? If you do, you gain X life and draw X cards.", source, game)) { int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { controller.resetStoredBookmark(game); // otherwise you can undo the payment controller.gainLife(costX, game, source); controller.drawCards(costX, game); return true; } } } return false; }
@Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); ManaCosts cost = new ManaCostsImpl("{X}"); if (you != null && you.chooseUse(Outcome.BoostCreature, "Do you want to to pay {X}?", source, game)) { int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null) { return new AddCountersSourceEffect(CounterType.P1P1.createInstance(costX), true).apply(game, source); } } } return false; } }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) { Player controller = game.getPlayer(controllerId); if (controller != null) { Card card = controller.getGraveyard().get(targets.getFirstTarget(), game); if (card != null && controller.moveCards(card, Zone.EXILED, ability, game)) { ability.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId()))); paid = card.getManaCost().pay(ability, game, sourceId, controllerId, noMana); } } } return paid; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); ManaCosts cost = new ManaCostsImpl("{X}"); if (player == null || !player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) { return false; } int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { return false; } game.addDelayedTriggeredAbility(new IsarethTheAwakenerReflexiveTriggeredAbility(), source); return new SendOptionUsedEventEffect(costX).apply(game, source); } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller == null || !controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) { return false; } TargetCardInHand target = new TargetCardInHand(new FilterCreatureCard()); if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.moveCards(card, Zone.BATTLEFIELD, source, game); ManaCosts<ManaCost> reducedCost = ManaCosts.removeVariableManaCost(CardUtil.reduceCost(card.getManaCost(), 2)); if (controller.chooseUse(Outcome.Benefit, String.valueOf("Pay " + reducedCost.getText()) + Character.toString('?'), source, game)) { reducedCost.clearPaid(); if (reducedCost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { return true; } } Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { permanent.sacrifice(source.getSourceId(), game); } return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { ManaCosts cost = new ManaCostsImpl("{5}{R}{R}"); if (player.chooseUse(Outcome.Damage, "Pay " + cost.getText() + '?', source, game)) { cost.clearPaid(); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { new UntapAllControllerEffect(new FilterAttackingCreature(),"").apply(game, source); game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false)); return true; } } } return false; }
private void processPlayer(Game game, Ability source, Player player) { MageObject sourceObject = game.getObject(source.getSourceId()); List<Permanent> creatures = getPermanentsWithTheHighestCMC(game, player.getId(), new FilterControlledCreaturePermanent()); Permanent creatureToPayFor = chooseOnePermanent(game, player, creatures); if (creatureToPayFor != null && sourceObject != null) { ManaCosts manaCost = ManaCosts.removeVariableManaCost(creatureToPayFor.getManaCost()); String message = "Pay " + manaCost.getText() + " (otherwise sacrifice " + creatureToPayFor.getName() + ")?"; if (player.chooseUse(Outcome.Benefit, message, source, game)) { if (manaCost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " has paid"); return; } } game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " hasn't paid"); creatureToPayFor.sacrifice(source.getSourceId(), game); } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); ManaCosts cost = new ManaCostsImpl("{X}"); if (player != null) { if (player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) { int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null && permanent.isCreature()) { ContinuousEffect effect = new BoostTargetEffect(costX, 0, Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(permanent.getId())); game.addEffect(effect, source); return true; } return false; } } } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); ManaCosts cost = new ManaCostsImpl("{X}{R}"); if (player != null) { if (player.chooseUse(Outcome.Damage, "Pay " + cost.getText() + "? If you do, Flameblast Dragon deals X damage to any target", source, game)) { int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { permanent.damage(costX, source.getSourceId(), game, false, true); return true; } Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (targetPlayer != null) { targetPlayer.damage(costX, source.getSourceId(), game, false, true); return true; } return false; } } } return false; }
@Override public boolean apply(Game game, Ability source) { UUID creatureId = (UUID) getValue("damageSource"); Permanent creature = game.getPermanentOrLKIBattlefield(creatureId); Player controller = game.getPlayer(source.getControllerId()); if (creature != null && controller != null) { if (controller.chooseUse(Outcome.Damage, "Pay {2}{R} to do the damage?", source, game)) { // if (controller.chooseUse(Outcome.Damage, "Pay {2}{R}? If you do, " + creature.getName() + " deals damage equal to its power to any target.", game)) { ManaCosts manaCosts = new ManaCostsImpl("{2}{R}"); if (manaCosts.pay(source, game, source.getSourceId(), controller.getId(), false, null)) { int amount = creature.getPower().getValue(); UUID target = source.getTargets().getFirstTarget(); Permanent targetCreature = game.getPermanent(target); if (targetCreature != null) { targetCreature.damage(amount, creature.getId(), game, false, true); } else { Player player = game.getPlayer(target); if (player != null) { player.damage(amount, creature.getId(), game, false, true); } } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { ManaCosts cost = new ManaCostsImpl("{X}{R}"); if (controller.chooseUse(outcome, "Pay " + cost.getText() + "? If you do, you create X 1/1 red Elemental creature tokens that are tapped and attacking.", source, game)) { int costX = controller.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source); cost.add(new GenericManaCost(costX)); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) { controller.resetStoredBookmark(game); // otherwise you can undo the payment CreateTokenEffect effect = new CreateTokenEffect(new TilonallisSummonerElementalToken(), costX, true, true); effect.apply(game, source); Effect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD) .setText("exile those tokens unless you have the city's blessing"); exileEffect.setTargetPointer(new FixedTargets(new CardsImpl(effect.getLastAddedTokenIds()), game)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility( Zone.ALL, exileEffect, TargetController.ANY, new InvertCondition(CitysBlessingCondition.instance)), source); } } return true; } return false; } }
xValue = player.announceXMana(0, Integer.MAX_VALUE, "Choose the amount of mana to pay", game, source); cost.add(new GenericManaCost(xValue)); if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { game.informPlayers(player.getLogName() + " paid {" + xValue + "} for " + permanent.getLogName()); } else {
if (!manaCostsToPay.pay(this, game, sourceId, activatorId, false, null)) { return false; // cancel during mana payment