@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { int numToDiscard = player.getAmount(0, player.getHand().size(), "Discard how many cards at random?", game); player.discard(numToDiscard, true, source, game); game.addEffect(new BoostControlledEffect(numToDiscard, 0, Duration.EndOfTurn), source); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { for (UUID playerId : getTargetPointer().getTargets(game, source)) { Player player = game.getPlayer(playerId); if (player != null) { int cardsToDraw = amount.calculate(game, source, this); if (upTo) { cardsToDraw = player.getAmount(0, cardsToDraw, "Draw how many cards?", game); } if (!optional || player.chooseUse(outcome, "Use draw effect?", source, game)) { player.drawCards(cardsToDraw, game); } } } return true; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); if (opponent != null) { int number = opponent.getAmount(0, 3, "Draw how many cards?", game); opponent.drawCards(number, game); } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int numToDiscard = player.getAmount(0, player.getHand().size(), "Discard how many cards?", game); player.discard(numToDiscard, false, source, game); player.drawCards(numToDiscard, game); } } return true; } }
@Override public boolean apply(Game game, Ability source) { String message = "Do you want to draw two cards and allow the spellcaster to draw up to four cards again?"; String message2 = "How many cards do you want to draw?"; Player controller = game.getPlayer(source.getControllerId()); Player targetOpponent = game.getPlayer(source.getFirstTarget()); if (controller != null && targetOpponent != null) { new DrawCardTargetEffect(2).apply(game, source);//The drawcard method would not work immediately int amountOfCardsToDraw = controller.getAmount(0, 4, message2, game); new DrawCardSourceControllerEffect(amountOfCardsToDraw).apply(game, source); while (targetOpponent.chooseUse(Outcome.AIDontUseIt, message, source, game)) { new DrawCardTargetEffect(2).apply(game, source); amountOfCardsToDraw = controller.getAmount(0, 4, message2, game); new DrawCardSourceControllerEffect(amountOfCardsToDraw).apply(game, source); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int cardsToDraw = player.getAmount(0, 2, "Draw how many cards?", game); player.drawCards(cardsToDraw, game); player.gainLife((2 - cardsToDraw) * 2, game, source); } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { int cardsToDraw = player.getAmount(0, 2, "Draw how many cards?", game); player.drawCards(cardsToDraw, game); player.gainLife((2 - cardsToDraw) * 2, game, source); } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getFirstTarget()); if (controller != null) { int amount = controller.getAmount(0, Integer.MAX_VALUE, "Choose the amount of damage to deliver to you and a target creature. The damage can't be prevented.", game); if (amount > 0) { controller.damage(amount, source.getSourceId(), game, false, false); if (permanent != null) { permanent.damage(amount, source.getSourceId(), game, false, false); } return true; } } return false; } }
@Override public Mana produceMana(boolean netMana, Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { Mana mana = new Mana(); int amountOfManaLeft = amount.calculate(game, source, this); int maxAmount = amountOfManaLeft; while (amountOfManaLeft > 0 && player.canRespond()) { for (ColoredManaSymbol coloredManaSymbol : manaSymbols) { int number = player.getAmount(0, amountOfManaLeft, "Distribute mana by color (done " + mana.count() + " of " + maxAmount + "). How many mana add to <b>" + coloredManaSymbol.getColorHtmlName() + "</b> (enter 0 for pass to next color)?", game); if (number > 0) { for (int i = 0; i < number; i++) { mana.add(new Mana(coloredManaSymbol)); } amountOfManaLeft -= number; } if (amountOfManaLeft == 0) { break; } } } return mana; } return null; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int numToDiscard = controller.getAmount(0, controller.getHand().getCards(new FilterCreatureCard(), game).size(), "Discard how many creature cards?", game); TargetCardInHand target = new TargetCardInHand(numToDiscard, new FilterCreatureCard()); if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { for (UUID targetId : target.getTargets()) { Card card = game.getCard(targetId); if (card != null && controller.discard(card, source, game)) { new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)).apply(game, source); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Permanent fromPermanent = game.getPermanent(source.getSourceId()); Permanent toPermanent = game.getPermanent(source.getTargets().getFirstTarget()); if (fromPermanent != null && toPermanent != null) { int amountCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1); if (amountCounters > 0) { int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", game); if (amountToMove > 0) { fromPermanent.removeCounters(CounterType.P1P1.createInstance(amountToMove), game); toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), source, game); } } return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { new GetEnergyCountersControllerEffect(3).apply(game, source); int numberToPay = controller.getAmount(0, controller.getCounters().getCount(CounterType.ENERGY), "How many {E} do you like to pay?", game); if (numberToPay > 0) { Cost cost = new PayEnergyCost(numberToPay); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetCreature != null) { targetCreature.damage(numberToPay, source.getSourceId(), game, false, true); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (controller == null || permanent == null) { return false; } int permanentsInPlay = new PermanentsOnBattlefieldCount(filter).calculate(game, source, null); int cardsInGraveyards = new CardsInAllGraveyardsCount(filter2).calculate(game, source, null); int maxAmount = Math.min(permanentsInPlay + cardsInGraveyards, controller.getLife()); int payAmount = controller.getAmount(0, maxAmount, "Pay up to " + maxAmount + " life", game); Cost cost = new PayLifeCost(payAmount); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } Card sourceCard = game.getCard(source.getSourceId()); game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() + " pays " + payAmount + " life"); game.addEffect(new SetPowerToughnessSourceEffect( payAmount, payAmount, Duration.Custom, SubLayer.CharacteristicDefining_7a ), source); permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game); return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller == null || sourceObject == null) { return false; } FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(ObjectColor.BLACK)); int blackCards = controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game); int cardsToReveal = controller.getAmount(0, blackCards, "Reveal how many black cards?", game); game.informPlayers(controller.getLogName() + " chooses to reveal " + cardsToReveal + " black cards."); if (cardsToReveal > 0) { TargetCardInHand target = new TargetCardInHand(cardsToReveal, cardsToReveal, filter); if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) { controller.revealCards(sourceObject.getIdName(), new CardsImpl(target.getTargets()), game); int unboost = target.getTargets().size() * -1; ContinuousEffect effect = new BoostTargetEffect(unboost, unboost, Duration.EndOfTurn); effect.setTargetPointer(getTargetPointer()); game.addEffect(effect, source); } } return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { new GetEnergyCountersControllerEffect(2).apply(game, source); int max = controller.getCounters().getCount(CounterType.ENERGY); int numberToPayed = controller.getAmount(0, max, "How many energy counters do you like to pay? (maximum = " + max + ')', game); if (numberToPayed > 0) { Cost cost = new PayEnergyCost(numberToPayed); if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetCreature != null) { numberToPayed *= -1; ContinuousEffect effect = new BoostTargetEffect(numberToPayed, numberToPayed, Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(targetCreature, game)); game.addEffect(effect, source); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (controller == null || permanent == null) { return false; } int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game); Cost cost = new PayLifeCost(payAmount); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } Card sourceCard = game.getCard(source.getSourceId()); game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() + " pays " + payAmount + " life"); game.addEffect(new SetPowerToughnessSourceEffect( payAmount, payAmount, Duration.Custom, SubLayer.CharacteristicDefining_7a ), source); permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game); return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent toPermanent = null; if (source.getTargets().size() > 1) { toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); } if (fromPermanent == null || toPermanent == null || !fromPermanent.isControlledBy(toPermanent.getControllerId())) { return false; } int amountCounters = fromPermanent.getCounters(game).getCount(CounterType.P1P1); if (amountCounters > 0) { int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", game); if (amountToMove > 0) { fromPermanent.removeCounters(CounterType.P1P1.createInstance(amountToMove), game); toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), source, game); } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (controller == null || permanent == null) { return false; } int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game); Cost cost = new PayLifeCost(payAmount); if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) { return false; } Card sourceCard = game.getCard(source.getSourceId()); game.informPlayers((sourceCard != null ? sourceCard.getName() : "") + ": " + controller.getLogName() + " pays " + payAmount + " life."); String key = CardUtil.getCardZoneString("lifePaid", source.getSourceId(), game); game.getState().setValue(key, payAmount); permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game); return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player targetOpponent = game.getPlayer(source.getFirstTarget()); ChoiceColor color = new ChoiceColor(); int amount = 0; if (controller != null && targetOpponent != null) { amount = controller.getAmount(1, Integer.MAX_VALUE, "Choose a number", game); controller.choose(Outcome.Discard, color, game); FilterCard filter = new FilterCard(); filter.add(new ColorPredicate(color.getColor())); targetOpponent.revealCards(source, targetOpponent.getHand(), game); if (targetOpponent.getHand().count(filter, game) == amount) { game.informPlayers(controller.getName() + " has chosen the exact number and color of the revealed cards from " + targetOpponent.getName() + "'s hand. They draw a card."); controller.drawCards(1, game); return true; } else { game.informPlayers(controller.getName() + " has chosen incorrectly and will not draw a card."); } } return false; }
@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; } }