Search in sources :

Example 6 with Mana

use of mage.Mana in project mage by magefree.

the class PulseOfLlanowarReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ManaEvent manaEvent = (ManaEvent) event;
    Mana mana = manaEvent.getMana();
    new AddManaOfAnyColorEffect(mana.count()).apply(game, source);
    mana.setToMana(new Mana(0, 0, 0, 0, 0, 0, 0, 0));
    return true;
}
Also used : AddManaOfAnyColorEffect(mage.abilities.effects.mana.AddManaOfAnyColorEffect) Mana(mage.Mana) ManaEvent(mage.game.events.ManaEvent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 7 with Mana

use of mage.Mana in project mage by magefree.

the class SquanderedResourcesEffect method getNetMana.

@Override
public List<Mana> getNetMana(Game game, Ability source) {
    if (game != null && game.inCheckPlayableState()) {
        // add color combinations of available mana
        ManaOptions allPossibleMana = new ManaOptions();
        for (Permanent land : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), game)) {
            ManaOptions currentPossibleMana = new ManaOptions();
            Set<ManaType> manaTypes = AnyColorLandsProduceManaAbility.getManaTypesFromPermanent(land, game);
            if (manaTypes.size() == 5 && !manaTypes.contains(ManaType.COLORLESS) || manaTypes.size() == 6) {
                currentPossibleMana.add(Mana.AnyMana(1));
                if (manaTypes.contains(ManaType.COLORLESS)) {
                    currentPossibleMana.add(new Mana(ManaType.COLORLESS));
                }
            } else {
                for (ManaType manaType : manaTypes) {
                    currentPossibleMana.add(new Mana(manaType));
                }
            }
            allPossibleMana.addMana(currentPossibleMana);
        }
        allPossibleMana.removeDuplicated();
        return allPossibleMana.stream().collect(Collectors.toList());
    }
    return ManaType.getManaListFromManaTypes(getManaTypesFromSacrificedPermanent(game, source), false);
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) Mana(mage.Mana) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) ManaType(mage.constants.ManaType)

Example 8 with Mana

use of mage.Mana in project mage by magefree.

the class ConditionalManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    if (condition.apply(game, source)) {
        mana = effect.getManaTemplate().copy();
    } else if (otherwiseEffect != null) {
        mana = otherwiseEffect.getManaTemplate().copy();
    }
    if (mana.getAny() > 0) {
        int amount = mana.getAny();
        Player controller = game.getPlayer(source.getControllerId());
        if (controller == null) {
            return mana;
        }
        ChoiceColor choice = new ChoiceColor(true);
        if (controller.choose(outcome, choice, game)) {
            mana.setAny(0);
            mana.add(choice.getMana(amount));
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) ChoiceColor(mage.choices.ChoiceColor)

Example 9 with Mana

use of mage.Mana in project mage by magefree.

the class DampingSphereIncreasementAllEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ManaEvent manaEvent = (ManaEvent) event;
    Mana mana = manaEvent.getMana();
    mana.setToMana(Mana.ColorlessMana(1));
    return false;
}
Also used : Mana(mage.Mana) ManaEvent(mage.game.events.ManaEvent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 10 with Mana

use of mage.Mana in project mage by magefree.

the class DomriAnarchOfBolasEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Mana mana = new Mana();
    if (player.chooseUse(outcome, "Choose a color of mana to add", null, "Red", "Green", source, game)) {
        mana.increaseRed();
    } else {
        mana.increaseGreen();
    }
    player.getManaPool().addMana(mana, game, source);
    game.addEffect(new CantBeCounteredControlledEffect(StaticFilters.FILTER_SPELL_A_CREATURE, Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) CantBeCounteredControlledEffect(mage.abilities.effects.common.CantBeCounteredControlledEffect)

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