Search in sources :

Example 76 with Mana

use of mage.Mana in project mage by magefree.

the class ManaOptions method addTriggeredMana.

private void addTriggeredMana(Game game, Ability ability) {
    List<List<Mana>> netManaList = getSimulatedTriggeredManaFromPlayer(game, ability);
    for (List<Mana> triggeredNetMana : netManaList) {
        if (triggeredNetMana.size() == 1) {
            addMana(triggeredNetMana.get(0));
        } else if (triggeredNetMana.size() > 1) {
            // Add variations
            List<Mana> copy = copy();
            this.clear();
            for (Mana triggeredMana : triggeredNetMana) {
                for (Mana mana : copy) {
                    Mana newMana = new Mana();
                    newMana.add(mana);
                    newMana.add(triggeredMana);
                    this.add(newMana);
                }
            }
        }
    }
    forceManaDeduplication();
}
Also used : Mana(mage.Mana) ConditionalMana(mage.ConditionalMana)

Example 77 with Mana

use of mage.Mana in project mage by magefree.

the class AnyColorLandsProduceManaEffect method getManaTypes.

private Mana getManaTypes(Game game, Ability source) {
    Mana types = new Mana();
    if (game == null || game.getPhase() == null) {
        return types;
    }
    if (inManaTypeCalculation) {
        return types;
    }
    inManaTypeCalculation = true;
    List<Permanent> lands = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, source.getControllerId(), source.getSourceId(), game);
    for (Permanent land : lands) {
        Abilities<ActivatedManaAbilityImpl> mana = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD);
        for (ActivatedManaAbilityImpl ability : mana) {
            if (!ability.equals(source) && ability.definesMana(game)) {
                for (Mana netMana : ability.getNetMana(game)) {
                    types.add(netMana);
                }
            }
        }
    }
    inManaTypeCalculation = false;
    return types;
}
Also used : Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ActivatedManaAbilityImpl(mage.abilities.mana.ActivatedManaAbilityImpl)

Example 78 with Mana

use of mage.Mana in project mage by magefree.

the class AnyColorLandsProduceManaEffect method getNetMana.

@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(Mana.RedMana(manaAmount));
    }
    if (types.getGreen() > 0) {
        netManas.add(Mana.GreenMana(manaAmount));
    }
    if (types.getBlue() > 0) {
        netManas.add(Mana.BlueMana(manaAmount));
    }
    if (types.getWhite() > 0) {
        netManas.add(Mana.WhiteMana(manaAmount));
    }
    if (types.getBlack() > 0) {
        netManas.add(Mana.BlackMana(manaAmount));
    }
    if (types.getColorless() > 0) {
        netManas.add(Mana.ColorlessMana(manaAmount));
    }
    if (types.getAny() > 0) {
        netManas.add(Mana.AnyMana(manaAmount));
    }
    return netManas;
}
Also used : Mana(mage.Mana) ArrayList(java.util.ArrayList)

Example 79 with Mana

use of mage.Mana in project mage by magefree.

the class KessigNaturalistEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Mana mana = player.chooseUse(Outcome.Neutral, "Choose red or green", null, "Red", "Green", source, game) ? Mana.RedMana(1) : Mana.GreenMana(1);
    player.getManaPool().addMana(mana, game, source, true);
    return true;
}
Also used : Player(mage.players.Player) Mana(mage.Mana)

Example 80 with Mana

use of mage.Mana in project mage by magefree.

the class LordOfTheUlvenwaldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Mana mana = player.chooseUse(Outcome.Neutral, "Choose red or green", null, "Red", "Green", source, game) ? Mana.RedMana(1) : Mana.GreenMana(1);
    player.getManaPool().addMana(mana, game, source, true);
    return true;
}
Also used : Player(mage.players.Player) Mana(mage.Mana)

Aggregations

Mana (mage.Mana)147 Player (mage.players.Player)76 ConditionalMana (mage.ConditionalMana)33 Permanent (mage.game.permanent.Permanent)32 ArrayList (java.util.ArrayList)26 Choice (mage.choices.Choice)23 ChoiceColor (mage.choices.ChoiceColor)23 ChoiceImpl (mage.choices.ChoiceImpl)14 TappedForManaEvent (mage.game.events.TappedForManaEvent)14 Card (mage.cards.Card)13 ManaEvent (mage.game.events.ManaEvent)11 ObjectColor (mage.ObjectColor)8 ManaOptions (mage.abilities.mana.ManaOptions)8 FilterMana (mage.filter.FilterMana)8 LinkedHashSet (java.util.LinkedHashSet)7 UUID (java.util.UUID)7 FilterPermanent (mage.filter.FilterPermanent)6 MageObject (mage.MageObject)5 ActivatedManaAbilityImpl (mage.abilities.mana.ActivatedManaAbilityImpl)5 FilterCard (mage.filter.FilterCard)5