private void removeConditional(ManaType manaType, Ability ability, Game game, Cost costToPay, Mana usedManaToPay) { for (ConditionalMana mana : getConditionalMana()) { if (mana.get(manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId(), costToPay)) { mana.set(manaType, mana.get(manaType) - 1); usedManaToPay.increase(manaType); GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAID, ability.getId(), mana.getManaProducerId(), ability.getControllerId(), 0, mana.getFlag()); event.setData(mana.getManaProducerOriginalId().toString()); game.fireEvent(event); break; } } }
public ManaPoolView(ManaPool pool) { this.red = pool.getRed(); this.green = pool.getGreen(); this.blue = pool.getBlue(); this.white = pool.getWhite(); this.black = pool.getBlack(); this.colorless = pool.getColorless(); for (ConditionalMana mana : pool.getConditionalMana()) { this.red += mana.getRed(); this.green += mana.getGreen(); this.blue += mana.getBlue(); this.white += mana.getWhite(); this.black += mana.getBlack(); this.colorless += mana.getColorless(); } }
@Override public ConditionalMana copy() { return new ConditionalMana(this); }
public int getConditionalCount(Ability ability, Game game, FilterMana filter, Cost costToPay) { if (ability == null || getConditionalMana().isEmpty()) { return 0; } int count = 0; for (ConditionalMana mana : getConditionalMana()) { if (mana.apply(ability, game, mana.getManaProducerId(), costToPay)) { count += mana.count(filter); } } return count; }
if (item.isConditional()) { ConditionalMana c = item.getConditionalMana(); if (c.apply(ability, game, c.getManaProducerId(), null)) { int count = c.count(filter); if (count > 0) { total += count; c.removeAll(filter); if (c.count() == 0) { it.remove();
private int payX(Ability ability, Game game) { int total = 0; Iterator<ManaPoolItem> it = manaItems.iterator(); while (it.hasNext()) { ManaPoolItem item = it.next(); if (item.isConditional()) { ConditionalMana cm = item.getConditionalMana(); if (cm.apply(ability, game, cm.getManaProducerId(), null)) { total += item.count(); it.remove(); } } else { total += item.count(); it.remove(); } } return total; }
private int getConditional(ManaType manaType, Ability ability, Filter filter, Game game, Cost costToPay) { if (ability == null || getConditionalMana().isEmpty()) { return 0; } for (ManaPoolItem mana : manaItems) { if (mana.isConditional() && mana.getConditionalMana().get(manaType) > 0 && mana.getConditionalMana().apply(ability, game, mana.getSourceId(), costToPay)) { if (filter == null || filter.match(mana.getSourceObject(), game)) { return mana.getConditionalMana().get(manaType); } } } return 0; }
if (conditionalItem.get(manaType) > 0) { if (item.getDuration() != Duration.EndOfTurn || game.getPhase().getType() == TurnPhase.END) { if (game.replaceEvent(new GameEvent(GameEvent.EventType.EMPTY_MANA_POOL, playerId, null, playerId))) { int amount = conditionalItem.get(manaType); conditionalItem.clear(manaType); conditionalItem.add(ManaType.COLORLESS, amount); } else { total += conditionalItem.get(manaType); conditionalItem.clear(manaType);
mana = new ConditionalMana(manaBuilder.setMana(choice.getMana(value), source, game).build()); break; } else { if (mana == null) { mana = new ConditionalMana(manaBuilder.setMana(choice.getMana(1), source, game).build()); } else { mana.add(choice.getMana(1));
for (Mana netMana : manaAbility.getNetMana(game)) { if (cost.testPay(netMana)) { if (netMana instanceof ConditionalMana && !((ConditionalMana) netMana).apply(ability, game, getId(), cost)) { continue; for (Mana netMana : manaAbility.getNetMana(game)) { if (cost.testPay(netMana) || permittingObject != null) { if (netMana instanceof ConditionalMana && !((ConditionalMana) netMana).apply(ability, game, getId(), cost)) { continue; for (Mana netMana : manaAbility.getNetMana(game)) { if (cost.testPay(netMana) || permittingObject != null) { if (netMana instanceof ConditionalMana && !((ConditionalMana) netMana).apply(ability, game, getId(), cost)) { continue; for (Mana netMana : manaAbility.getNetMana(game)) { if (cost.testPay(netMana) || permittingObject != null) { if (netMana instanceof ConditionalMana && !((ConditionalMana) netMana).apply(ability, game, getId(), cost)) { continue; for (Mana netMana : manaAbility.getNetMana(game)) { if (cost.testPay(netMana) || permittingObject != null) { if (netMana instanceof ConditionalMana && !((ConditionalMana) netMana).apply(ability, game, getId(), cost)) { continue; for (Mana netMana : manaAbility.getNetMana(game)) { if (cost.testPay(netMana) || permittingObject != null) { if (netMana instanceof ConditionalMana && !((ConditionalMana) netMana).apply(ability, game, getId(), cost)) { continue;
@Override public Mana produceMana(boolean netMana, Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { return null; } ManaPool pool = controller.getManaPool(); int blackMana = pool.getBlack(); int whiteMana = pool.getWhite(); int blueMana = pool.getBlue(); int greenMana = pool.getGreen(); int redMana = pool.getRed(); int colorlessMana = pool.getColorless(); for (ConditionalMana conditionalMana : pool.getConditionalMana()) { blackMana += conditionalMana.getBlack(); whiteMana += conditionalMana.getWhite(); blueMana += conditionalMana.getBlue(); greenMana += conditionalMana.getGreen(); redMana += conditionalMana.getRed(); colorlessMana += conditionalMana.getColorless(); } return new Mana(redMana, greenMana, blueMana, whiteMana, blackMana, 0, 0, colorlessMana); }