@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (player != null) { GenericManaCost cost = new GenericManaCost(1); if (!cost.pay(source, game, player.getId(), player.getId(), false)) { super.apply(game, source); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (player != null) { GenericManaCost cost = new GenericManaCost(1); if (!cost.pay(source, game, player.getId(), player.getId(), false)) { super.apply(game, source); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { GenericManaCost cost = new GenericManaCost(2); if (!cost.pay(source, game, player.getId(), player.getId(), false)) { player.damage(2, source.getSourceId(), game, false, true); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (player != null && controller != null && sourceObject != null) { int amount = new GreatestPowerCountCreatureYouControl().calculate(game, source, this); GenericManaCost cost = new GenericManaCost(amount); StringBuilder sb = new StringBuilder("Pay {").append(amount).append("}? (otherwise ").append(spell.getName()).append(" will be countered)"); if (player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) { cost.pay(source, game, source.getSourceId(), player.getId(), false); } if (!cost.isPaid()) { if (game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) { game.informPlayers(sourceObject.getName() + ": cost wasn't payed - countering " + spell.getName()); return true; } } } } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int amount = (Integer) getValue("gainedLife"); if (amount > 0) { int xValue = controller.announceXMana(0, amount, "Announce X Value", game, source); if (xValue > 0) { if (new GenericManaCost(xValue).pay(source, game, source.getSourceId(), controller.getId(), false)) { game.informPlayers(controller.getLogName() + " payed {" + xValue + '}'); controller.drawCards(xValue, game); } else { return false; } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Permanent permanent = game.getPermanent(source.getSourceId()); if (player != null && permanent != null) { GenericManaCost cost = new GenericManaCost(2); String message = "Would you like to pay {2} to prevent taking 2 damage from " + permanent.getLogName() + "?"; if (!(player.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source.getSourceId(), player.getId(), false, null))) { player.damage(2, source.getSourceId(), game, false, true); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); if (player != null) { GenericManaCost cost = new GenericManaCost(spell.getConvertedManaCost()); if (!cost.pay(source, game, source.getSourceId(), player.getId(), false)) { game.getStack().counter(spell.getId(), source.getSourceId(), game); } return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player != null && sourcePermanent != null) { int countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size(); while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.AIDontUseIt, "Pay {2} and untap a tapped nongreen creature under your control?", source, game)) { Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter, true); if (player.choose(Outcome.Detriment, tappedCreatureTarget, source.getSourceId(), game)) { GenericManaCost cost = new GenericManaCost(2); Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget()); if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) { tappedCreature.untap(game); } } countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size(); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player != null && sourcePermanent != null) { int countBattlefield = game.getBattlefield().getAllActivePermanents(filter2, game.getActivePlayerId(), game).size(); while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.AIDontUseIt, "Pay {4} and untap a tapped blue creature under your control?", source, game)) { Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter2, true); if (player.choose(Outcome.Detriment, tappedCreatureTarget, source.getSourceId(), game)) { GenericManaCost cost = new GenericManaCost(4); Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget()); if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) { tappedCreature.untap(game); } } countBattlefield = game.getBattlefield().getAllActivePermanents(filter2, game.getActivePlayerId(), game).size(); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (player != null && sourcePermanent != null) { int countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size(); while (player.canRespond() && countBattlefield > 0 && player.chooseUse(Outcome.AIDontUseIt, "Pay {2} and untap a tapped creature without flying under your control?", source, game)) { Target tappedCreatureTarget = new TargetControlledCreaturePermanent(1, 1, filter, true); if (player.choose(Outcome.Detriment, tappedCreatureTarget, source.getSourceId(), game)) { GenericManaCost cost = new GenericManaCost(2); Permanent tappedCreature = game.getPermanent(tappedCreatureTarget.getFirstTarget()); if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) { tappedCreature.untap(game); } } countBattlefield = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size(); } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); if (player != null) { GenericManaCost cost = new GenericManaCost(spell.getConvertedManaCost()); if (!cost.pay(source, game, source.getSourceId(), player.getId(), false)) { game.getStack().counter(spell.getId(), source.getSourceId(), game); } return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); if (player != null && permanent != null) { PermanentsOnBattlefieldCount amount = new PermanentsOnBattlefieldCount(filter, 1); int count = amount.calculate(game, source, this); if (player.chooseUse(Outcome.Benefit, "Pay " + count + "? Or " + permanent.getName() + " will be sacrificed.", source, game)) { GenericManaCost cost = new GenericManaCost(count); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { return true; } } permanent.sacrifice(source.getSourceId(), game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); if (player != null && permanent != null) { // The cost is reduced by {2} for each basic land type. int domainValueReduction = new DomainValue(2).calculate(game, source, this); int count = MAX_DOMAIN_VALUE - domainValueReduction; if (player.chooseUse(Outcome.Benefit, "Pay {" + count + "}? Or " + permanent.getName() + " will be sacrificed.", source, game)) { GenericManaCost cost = new GenericManaCost(count); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { return true; } } permanent.sacrifice(source.getSourceId(), game); return true; } return false; }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Player player = game.getPlayer(controllerId); if (player == null) { return false; } paid = false; if (player.getHand().count(filter, game) > 0 && player.chooseUse(Outcome.Benefit, "Reveal a Merfolk card? Otherwise pay {3}.", ability, game)) { TargetCardInHand target = new TargetCardInHand(filter); if (player.choose(Outcome.Benefit, target, sourceId, game)) { Card card = player.getHand().get(target.getFirstTarget(), game); if (card != null) { paid = true; player.revealCards("Revealed card", new CardsImpl(card), game); } } } else { mana.clearPaid(); if (mana.pay(ability, game, player.getId(), player.getId(), false)) { paid = true; } } return paid; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Spell targetSpell = game.getStack().getSpell(source.getFirstTarget()); if (targetSpell != null) { Player controllerOfTargetedSpell = game.getPlayer(targetSpell.getControllerId()); if (controller != null && controllerOfTargetedSpell != null) { int numToDiscard = controller.getAmount(0, controller.getHand().size(), "How many cards do you want to discard?", game); Cards discardedCards = controller.discard(numToDiscard, false, source, game); int actualNumberDiscarded = discardedCards.size(); GenericManaCost cost = new GenericManaCost(actualNumberDiscarded * 3); if (controllerOfTargetedSpell.chooseUse(Outcome.AIDontUseIt, "Do you want to pay " + cost.convertedManaCost() + " to prevent " + targetSpell.getName() + " from gettting countered?", source, game) && cost.pay(source, game, source.getSourceId(), controllerOfTargetedSpell.getId(), false)) { return true; } else { targetSpell.counter(source.getSourceId(), game); return true; } } } return false; } }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); if (player != null && controller != null) { int amount = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game); if (amount == 0) { game.informPlayers("Spell Syphon: no blue permanents in controller's battlefield."); } else { GenericManaCost cost = new GenericManaCost(amount); if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) { game.informPlayers("Spell Syphon: cost wasn't payed - countering target spell."); return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game); } } } } return false; }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && spell != null) { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); if (player != null && controller != null) { int amount = controller.getHand().size(); if (amount > 0) { GenericManaCost cost = new GenericManaCost(amount); if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) { game.informPlayers(sourceObject.getLogName() + ": cost wasn't payed - countering target spell."); return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game); } } return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && spell != null) { Player player = game.getPlayer(spell.getControllerId()); Player controller = game.getPlayer(source.getControllerId()); if (player != null && controller != null) { int amount = game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game); if (amount > 0) { GenericManaCost cost = new GenericManaCost(amount); if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) { game.informPlayers(sourceObject.getLogName() + ": cost wasn't payed - countering target spell."); return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game); } } return true; } } return false; }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); if (player != null) { DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); boolean condition = watcher != null && watcher.castWithConditionTrue(source.getId()); if (!condition) { for (Cost cost: source.getCosts()) { if (cost instanceof RevealTargetFromHandCost) { condition = ((RevealTargetFromHandCost)cost).getNumberRevealedCards() > 0; } } } if (condition) { return game.getStack().counter(spell.getId(), source.getSourceId(), game); } if (!(player.chooseUse(Outcome.Benefit, "Would you like to pay {1} to prevent counter effect?", source, game) && new GenericManaCost(1).pay(source, game, spell.getSourceId(), spell.getControllerId(), false))) { return game.getStack().counter(spell.getId(), source.getSourceId(), game); } } } return true; }
@Override public boolean apply(Game game, Ability source) { StackObject spell = game.getStack().getStackObject(targetPointer.getFirst(game, source)); MageObject sourceObject = source.getSourceObject(game); if ((spell instanceof Spell) && sourceObject != null) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int amount = source.getManaCostsToPay().getX(); if (amount > 0) { GenericManaCost cost = new GenericManaCost(amount); if (!cost.pay(source, game, spell.getControllerId(), spell.getControllerId(), false)) { StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget()); if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId()))) { game.informPlayers(sourceObject.getIdName() + ": cost wasn't payed - countering " + stackObject.getName()); game.rememberLKI(source.getFirstTarget(), Zone.STACK, stackObject); controller.moveCards((Spell) spell, Zone.EXILED, source, game); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, source.getFirstTarget(), source.getSourceId(), stackObject.getControllerId())); return true; } return false; } } } } return false; }