@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Mana mana = getMana(game, source); if (mana.getGreen() > 0) { controller.getManaPool().addMana(mana, game, source); controller.gainLife(mana.getGreen(), game, source); } return true; } return false; }
@Override public void adjustCosts(Ability ability, Game game) { super.adjustCosts(ability, game); int reductionAmount = game.getBattlefield().count(filter, ability.getSourceId(), ability.getControllerId(), game); Iterator<ManaCost> iter = ability.getManaCostsToPay().iterator(); while ( reductionAmount > 0 && iter.hasNext() ) { ManaCost manaCost = iter.next(); if (manaCost.getMana().getGreen() > 0) { // in case another effect adds additional mana cost iter.remove(); reductionAmount--; } } }
@Override public List<Mana> getNetMana(Game game, Ability source) { List<Mana> netManas = new ArrayList<>(); Mana types = getManaTypes(game, source); if (types.getBlack() > 0) { netManas.add(new Mana(ColoredManaSymbol.B)); } if (types.getRed() > 0) { netManas.add(new Mana(ColoredManaSymbol.R)); } if (types.getBlue() > 0) { netManas.add(new Mana(ColoredManaSymbol.U)); } if (types.getGreen() > 0) { netManas.add(new Mana(ColoredManaSymbol.G)); } if (types.getWhite() > 0) { netManas.add(new Mana(ColoredManaSymbol.W)); } return netManas; }
protected boolean isColoredPaid(ColoredManaSymbol mana) { switch (mana) { case B: return this.payment.getBlack() > 0; case U: return this.payment.getBlue() > 0; case W: return this.payment.getWhite() > 0; case G: return this.payment.getGreen() > 0; case R: return this.payment.getRed() > 0; } return false; }
@Override public List<Mana> getNetMana(Game game, Ability source) { List<Mana> netManas = new ArrayList<>(); Mana types = getManaTypesInGraveyard(game, source); if (types == null) { return null; } if (types.getBlack() > 0) { netManas.add(new Mana(ColoredManaSymbol.B)); } if (types.getRed() > 0) { netManas.add(new Mana(ColoredManaSymbol.R)); } if (types.getBlue() > 0) { netManas.add(new Mana(ColoredManaSymbol.U)); } if (types.getGreen() > 0) { netManas.add(new Mana(ColoredManaSymbol.G)); } if (types.getWhite() > 0) { netManas.add(new Mana(ColoredManaSymbol.W)); } return netManas; }
@Override public List<Mana> getNetMana(Game game, Ability source) { List<Mana> netManas = new ArrayList<>(); Mana types = getManaTypes(game, source); if (types.getBlack() > 0) { netManas.add(new Mana(ColoredManaSymbol.B)); } if (types.getRed() > 0) { netManas.add(new Mana(ColoredManaSymbol.R)); } if (types.getBlue() > 0) { netManas.add(new Mana(ColoredManaSymbol.U)); } if (types.getGreen() > 0) { netManas.add(new Mana(ColoredManaSymbol.G)); } if (types.getWhite() > 0) { netManas.add(new Mana(ColoredManaSymbol.W)); } if (types.getGeneric() > 0) { netManas.add(Mana.ColorlessMana(1)); } return netManas; }
@Override public List<Mana> getNetMana(Game game, Ability source) { List<Mana> netManas = new ArrayList<>(); Mana types = getManaTypes(game, source); if (types.getBlack() > 0) { netManas.add(new Mana(ColoredManaSymbol.B)); } if (types.getRed() > 0) { netManas.add(new Mana(ColoredManaSymbol.R)); } if (types.getBlue() > 0) { netManas.add(new Mana(ColoredManaSymbol.U)); } if (types.getGreen() > 0) { netManas.add(new Mana(ColoredManaSymbol.G)); } if (types.getWhite() > 0) { netManas.add(new Mana(ColoredManaSymbol.W)); } if (types.getGeneric() > 0) { netManas.add(Mana.ColorlessMana(1)); } return netManas; }
@Override public List<Mana> getNetMana(Game game, Ability source) { List<Mana> netManas = new ArrayList<>(); Mana types = getManaTypes(game, source); if (types.getBlack() > 0) { netManas.add(new Mana(ColoredManaSymbol.B)); } if (types.getRed() > 0) { netManas.add(new Mana(ColoredManaSymbol.R)); } if (types.getBlue() > 0) { netManas.add(new Mana(ColoredManaSymbol.U)); } if (types.getGreen() > 0) { netManas.add(new Mana(ColoredManaSymbol.G)); } if (types.getWhite() > 0) { netManas.add(new Mana(ColoredManaSymbol.W)); } if (types.getColorless() > 0) { netManas.add(Mana.ColorlessMana(1)); } if (types.getAny() > 0) { netManas.add(Mana.AnyMana(1)); } return netManas; }
@Override public List<Mana> getNetMana(Game game, Ability source) { List<Mana> netManas = new ArrayList<>(); Mana types = getManaTypes(game, source); if (types.getBlack() > 0) { netManas.add(new Mana(ColoredManaSymbol.B)); } if (types.getRed() > 0) { netManas.add(new Mana(ColoredManaSymbol.R)); } if (types.getBlue() > 0) { netManas.add(new Mana(ColoredManaSymbol.U)); } if (types.getGreen() > 0) { netManas.add(new Mana(ColoredManaSymbol.G)); } if (types.getWhite() > 0) { netManas.add(new Mana(ColoredManaSymbol.W)); } if (types.getColorless() > 0) { netManas.add(Mana.ColorlessMana(1)); } if (types.getAny() > 0) { netManas.add(Mana.AnyMana(1)); } return netManas; }
@Override public List<Mana> getNetMana(Game game, Ability source) { int manaAmount = getManaAmount(game, source); List<Mana> netManas = new ArrayList(); Mana types = getManaTypes(game, source); if (types.getRed() > 0) { netManas.add(new Mana(manaAmount, 0, 0, 0, 0, 0, 0, 0)); } if (types.getGreen() > 0) { netManas.add(new Mana(0, manaAmount, 0, 0, 0, 0, 0, 0)); } if (types.getBlue() > 0) { netManas.add(new Mana(0, 0, manaAmount, 0, 0, 0, 0, 0)); } if (types.getWhite() > 0) { netManas.add(new Mana(0, 0, 0, manaAmount, 0, 0, 0, 0)); } if (types.getBlack() > 0) { netManas.add(new Mana(0, 0, 0, 0, manaAmount, 0, 0, 0)); } if (types.getColorless() > 0) { netManas.add(new Mana(0, 0, 0, 0, 0, 0, 0, manaAmount)); } if (types.getAny() > 0) { netManas.add(new Mana(0, 0, 0, 0, 0, 0, manaAmount, 0)); } return netManas; }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { chroma = 0; for (Card card : game.getBattlefield().getAllActivePermanents(new FilterControlledPermanent(), sourceAbility.getControllerId(), game)) { chroma += card.getManaCost().getMana().getGreen(); } return chroma; }
@Override public boolean testPay(Mana testMana) { if (testMana.getAny() > 0) { return true; } switch (mana) { case B: return testMana.getBlack() > 0; case U: return testMana.getBlue() > 0; case R: return testMana.getRed() > 0; case W: return testMana.getWhite() > 0; case G: return testMana.getGreen() > 0; } return false; }
private Choice buildChoice(ObjectColor creatureColor, Mana mana) { Choice choice = new ChoiceColor(); choice.getChoices().clear(); if (creatureColor.isBlack() && mana.getBlack() > 0) { choice.getChoices().add("Black"); } if (creatureColor.isBlue() && mana.getBlue() > 0) { choice.getChoices().add("Blue"); } if (creatureColor.isGreen() && mana.getGreen() > 0) { choice.getChoices().add("Green"); } if (creatureColor.isRed() && mana.getRed() > 0) { choice.getChoices().add("Red"); } if (creatureColor.isWhite() && mana.getWhite() > 0) { choice.getChoices().add("White"); } return choice; } }
@Override public boolean testPay(Mana testMana) { switch (mana) { case B: if (testMana.getBlack() > 0) { return true; } case U: if (testMana.getBlue() > 0) { return true; } case R: if (testMana.getRed() > 0) { return true; } case W: if (testMana.getWhite() > 0) { return true; } case G: if (testMana.getGreen() > 0) { return true; } } return testMana.count() > 0; }
/** * Adds mana from the passed in {@link Mana} object to this object. * * @param mana mana to add to this object. */ public void add(final Mana mana) { red += mana.getRed(); green += mana.getGreen(); blue += mana.getBlue(); white += mana.getWhite(); black += mana.getBlack(); generic += mana.getGeneric(); colorless += mana.getColorless(); any += mana.getAny(); }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Mana mana = ((ManaEvent) event).getMana(); if (mana.getBlack() > 0) { mana.set(ManaType.BLACK, mana.getBlack() * 2); } if (mana.getBlue() > 0) { mana.set(ManaType.BLUE, mana.getBlue() * 2); } if (mana.getWhite() > 0) { mana.set(ManaType.WHITE, mana.getWhite() * 2); } if (mana.getGreen() > 0) { mana.set(ManaType.GREEN, mana.getGreen() * 2); } if (mana.getRed() > 0) { mana.set(ManaType.RED, mana.getRed() * 2); } if (mana.getColorless() > 0) { mana.set(ManaType.COLORLESS, mana.getColorless() * 2); } return false; }
@Override public int calculate(Game game, Ability source, Effect effect) { int count = 0; if (!game.getStack().isEmpty()) { StackObject spell = game.getStack().getFirst(); if (spell instanceof Spell && ((Spell) spell).getSourceId().equals(source.getSourceId())) { Mana mana = ((Spell) spell).getSpellAbility().getManaCostsToPay().getPayment(); if (mana.getBlack() > 0) { count++; } if (mana.getBlue() > 0) { count++; } if (mana.getGreen() > 0) { count++; } if (mana.getRed() > 0) { count++; } if (mana.getWhite() > 0) { count++; } } } return count; }
public void addMana(Mana manaToAdd, Game game, Ability source, boolean emptyOnTurnsEnd) { if (manaToAdd != null) { Mana mana = manaToAdd.copy(); if (!game.replaceEvent(new ManaEvent(EventType.ADD_MANA, source.getId(), source.getSourceId(), playerId, mana))) { if (mana instanceof ConditionalMana) { ManaPoolItem item = new ManaPoolItem((ConditionalMana) mana, source.getSourceObject(game), ((ConditionalMana) mana).getManaProducerOriginalId() != null ? ((ConditionalMana) mana).getManaProducerOriginalId() : source.getOriginalId()); if (emptyOnTurnsEnd) { item.setDuration(Duration.EndOfTurn); } this.manaItems.add(item); } else { ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getGeneric() + mana.getColorless(), source.getSourceObject(game), source.getOriginalId(), mana.getFlag()); if (emptyOnTurnsEnd) { item.setDuration(Duration.EndOfTurn); } this.manaItems.add(item); } ManaEvent manaEvent = new ManaEvent(EventType.MANA_ADDED, source.getId(), source.getSourceId(), playerId, mana); manaEvent.setData(mana.toString()); game.fireEvent(manaEvent); } } }
@Override public boolean apply(Game game, Ability source) { int chroma = 0; Player player = game.getPlayer(source.getControllerId()); if (player == null) { return false; } Cards cards = new CardsImpl(); if (player.getHand().count(new FilterCard(), game) > 0) { TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCard()); if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) { for (UUID uuid : target.getTargets()) { cards.add(player.getHand().get(uuid, game)); } player.revealCards("cards", cards, game); for (Card card : cards.getCards(game)) { chroma += card.getManaCost().getMana().getGreen(); } player.gainLife(chroma * 2, game, source); } } return true; } }
@Override public Mana produceMana(boolean netMana, Game game, Ability source) { Mana mana = new Mana(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) { if (mana.getBlack() == 0 && permanent.getColor(game).isBlack()) { mana.increaseBlack(); } if (mana.getBlue() == 0 && permanent.getColor(game).isBlue()) { mana.increaseBlue(); } if (mana.getRed() == 0 && permanent.getColor(game).isRed()) { mana.increaseRed(); } if (mana.getGreen() == 0 && permanent.getColor(game).isGreen()) { mana.increaseGreen(); } if (mana.getWhite() == 0 && permanent.getColor(game).isWhite()) { mana.increaseWhite(); } } return mana; } }