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 boolean ConditionalManaHasManaType(ManaType manaType) { for (ManaPoolItem item : manaItems) { if (item.isConditional()) { if (item.getConditionalMana().get(manaType) > 0) { return true; } } } return false; }
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; }
@Override public int calculate(Game game, Ability sourceAbility, Effect effect) { int amount = 0; Player player = game.getPlayer(sourceAbility.getControllerId()); if (player != null) { amount = player.getManaPool().get(manaType); for (ConditionalMana mana : player.getManaPool().getConditionalMana()) { amount += mana.get(manaType); } } return amount; }
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);