Search in sources :

Example 1 with HybridManaCost

use of mage.abilities.costs.mana.HybridManaCost in project mage by magefree.

the class OfferingCostReductionEffect method getManaOptions.

@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
    ManaOptions additionalManaOptionsForThisAbility = new ManaOptions();
    // Creatures from the offerd type
    game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game).stream().map(Card::getSpellAbility).filter(Objects::nonNull).forEach(spellAbility -> {
        ManaOptions manaOptionsForThisPermanent = new ManaOptions();
        for (ManaCost manaCost : spellAbility.getManaCosts()) {
            if (manaCost instanceof HybridManaCost) {
                ManaOptions manaOptionsForHybrid = new ManaOptions();
                manaOptionsForHybrid.addAll(manaCost.getManaOptions());
                manaOptionsForThisPermanent.addMana(manaOptionsForHybrid);
            } else {
                manaOptionsForThisPermanent.addMana(manaCost.getMana());
            }
        }
        additionalManaOptionsForThisAbility.addAll(manaOptionsForThisPermanent);
    });
    additionalManaOptionsForThisAbility.removeDuplicated();
    return additionalManaOptionsForThisAbility;
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) HybridManaCost(mage.abilities.costs.mana.HybridManaCost) HybridManaCost(mage.abilities.costs.mana.HybridManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) Card(mage.cards.Card)

Aggregations

HybridManaCost (mage.abilities.costs.mana.HybridManaCost)1 ManaCost (mage.abilities.costs.mana.ManaCost)1 ManaOptions (mage.abilities.mana.ManaOptions)1 Card (mage.cards.Card)1