@Override public boolean apply(Game game, Ability source) { Mana types = getManaTypes(game, source); Choice choice = new ChoiceImpl(true); choice.setMessage("Pick a mana color"); if (types.getBlack() > 0) { choice.getChoices().add("Black"); } if (types.getRed() > 0) { choice.getChoices().add("Red"); } if (types.getBlue() > 0) { choice.getChoices().add("Blue"); } if (types.getGreen() > 0) { choice.getChoices().add("Green"); } if (types.getWhite() > 0) { choice.getChoices().add("White"); } if (types.getAny() > 0) { choice.getChoices().add("Black"); choice.getChoices().add("Red"); choice.getChoices().add("Blue"); choice.getChoices().add("Green"); choice.getChoices().add("White"); } if (choice.getChoices().size() > 0) { Player player = game.getPlayer(source.getControllerId()); if (choice.getChoices().size() == 1) { choice.setChoice(choice.getChoices().iterator().next()); } else { player.choose(outcome, choice, game); } if (choice.getChoice() != null) { Mana mana = new Mana(); switch (choice.getChoice()) { case "Black": mana.setBlack(1); break; case "Blue": mana.setBlue(1); break; case "Red": mana.setRed(1); break; case "Green": mana.setGreen(1); break; case "White": mana.setWhite(1); break; } checkToFirePossibleEvents(mana, game, source); player.getManaPool().addMana(mana, game, source); } } return true; }
@java.lang.Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); Player player = game.getPlayer(source.getControllerId()); if (permanent != null && player != null) { List<UUID> imprinted = permanent.getImprinted(); if (imprinted.size() > 0) { Card imprintedCard = game.getCard(imprinted.get(0)); if (imprintedCard != null) { Choice choice = new ChoiceImpl(true); choice.setMessage("Pick a mana color"); ObjectColor color = imprintedCard.getColor(game); if (color.isBlack()) { choice.getChoices().add("Black"); } if (color.isRed()) { choice.getChoices().add("Red"); } if (color.isBlue()) { choice.getChoices().add("Blue"); } if (color.isGreen()) { choice.getChoices().add("Green"); } if (color.isWhite()) { choice.getChoices().add("White"); } if (choice.getChoices().size() > 0) { Mana mana = new Mana(); if (choice.getChoices().size() == 1) { choice.setChoice(choice.getChoices().iterator().next()); } else { player.choose(outcome, choice, game); } if (choice.getChoice().equals("Black")) { player.getManaPool().addMana(Mana.BlackMana, game, source); } else if (choice.getChoice().equals("Blue")) { player.getManaPool().addMana(Mana.BlueMana, game, source); } else if (choice.getChoice().equals("Red")) { player.getManaPool().addMana(Mana.RedMana, game, source); } else if (choice.getChoice().equals("Green")) { player.getManaPool().addMana(Mana.GreenMana, game, source); } else if (choice.getChoice().equals("White")) { player.getManaPool().addMana(Mana.WhiteMana, game, source); } else if (choice.getChoice().equals("Colorless")) { player.getManaPool().addMana(Mana.ColorlessMana, game, source); } checkToFirePossibleEvents(mana, game, source); player.getManaPool().addMana(mana, game, source); } } } } return true; }
@Override public boolean choose(Outcome outcome, Choice choice, Game game) { Iterator<String> it = choice.getChoices().iterator(); String sChoice = it.next(); int choiceNum = rnd.nextInt(choice.getChoices().size()); for (int i = 0; i < choiceNum; i++) { sChoice = it.next(); } choice.setChoice(sChoice); return true; }
@Override public void adjustCosts(Ability ability, Game game) { Player player = game.getPlayer(controllerId); if (player == null || !(ability instanceof SpellAbility)) { return; } Target target = new TargetControlledCreaturePermanent(1, Integer.MAX_VALUE, filter, true); target.setTargetName("creatures to convoke"); if (!target.canChoose(sourceId, controllerId, game)) { return; } if (player.chooseUse(Outcome.Detriment, "Convoke creatures?", game)) { player.chooseTarget(Outcome.Tap, target, ability, game); if (target.getTargets().size() > 0) { int adjCost = 0; for (UUID creatureId : target.getTargets()) { Permanent perm = game.getPermanent(creatureId); if (perm == null) { continue; } ManaCosts manaCostsCreature = perm.getSpellAbility().getManaCosts(); if (manaCostsCreature != null && manaCostsCreature.convertedManaCost() > 0 && perm.tap(game)) { Choice chooseManaType = buildChoice(manaCostsCreature, ability.getManaCostsToPay()); if (chooseManaType.getChoices().size() > 0) { if (chooseManaType.getChoices().size() > 1) { chooseManaType.getChoices().add("Colorless"); chooseManaType.setMessage("Choose mana color to reduce from " + perm.getName()); while (!chooseManaType.isChosen()) { player.choose(Outcome.Benefit, chooseManaType, game); } } else { chooseManaType.setChoice(chooseManaType.getChoices().iterator().next()); } ManaCosts manaCostsToReduce = new ManaCostsImpl(); if (chooseManaType.getChoice().equals("Black")) { manaCostsToReduce.load("{B}"); } if (chooseManaType.getChoice().equals("Blue")) { manaCostsToReduce.load("{U}"); } if (chooseManaType.getChoice().equals("Green")) { manaCostsToReduce.load("{G}"); } if (chooseManaType.getChoice().equals("White")) { manaCostsToReduce.load("{W}"); } if (chooseManaType.getChoice().equals("Red")) { manaCostsToReduce.load("{R}"); } if (chooseManaType.getChoice().equals("Colorless")) { ++adjCost; } CardUtil.adjustCost((SpellAbility) ability, manaCostsToReduce); } else { ++adjCost; } } } this.getTargets().add(target); CardUtil.adjustCost((SpellAbility) ability, adjCost); } } }