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; }
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; }
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; } } }
if (item.isConditional()) { ConditionalMana c = item.getConditionalMana(); if (c.apply(ability, game, c.getManaProducerId(), null)) { int count = c.count(filter); if (count > 0) {