Search in sources :

Example 56 with Mana

use of mage.Mana in project mage by magefree.

the class InfernalDarknessReplacementEffect method replaceEvent.

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

Example 57 with Mana

use of mage.Mana in project mage by magefree.

the class AnyColorLandsProduceManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    int manaAmount = getManaAmount(game, source);
    Mana types = getManaTypes(game, source);
    Choice choice = new ChoiceColor(true);
    choice.getChoices().clear();
    choice.setMessage("Pick a mana color");
    if (types.getBlack() > 0) {
        choice.getChoices().add("Black");
    }
    if (types.getRed() > 0) {
        choice.getChoices().add("Red");
    }
    if (types.getBlue() > 0) {
        choice.getChoices().add("Blue");
    }
    if (types.getGreen() > 0) {
        choice.getChoices().add("Green");
    }
    if (types.getWhite() > 0) {
        choice.getChoices().add("White");
    }
    if (types.getColorless() > 0) {
        choice.getChoices().add("Colorless");
    }
    if (types.getAny() > 0) {
        choice.getChoices().add("Black");
        choice.getChoices().add("Red");
        choice.getChoices().add("Blue");
        choice.getChoices().add("Green");
        choice.getChoices().add("White");
        choice.getChoices().add("Colorless");
    }
    if (!choice.getChoices().isEmpty()) {
        Player player = game.getPlayer(source.getControllerId());
        if (choice.getChoices().size() == 1) {
            choice.setChoice(choice.getChoices().iterator().next());
        } else if (player == null || !player.choose(outcome, choice, game)) {
            return mana;
        }
        if (choice.getChoice() != null) {
            switch(choice.getChoice()) {
                case "Black":
                    mana.setBlack(manaAmount);
                    break;
                case "Blue":
                    mana.setBlue(manaAmount);
                    break;
                case "Red":
                    mana.setRed(manaAmount);
                    break;
                case "Green":
                    mana.setGreen(manaAmount);
                    break;
                case "White":
                    mana.setWhite(manaAmount);
                    break;
                case "Colorless":
                    mana.setColorless(manaAmount);
                    break;
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) ChoiceColor(mage.choices.ChoiceColor)

Example 58 with Mana

use of mage.Mana in project mage by magefree.

the class ManaforgeCinderManaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice manaChoice = new ChoiceImpl();
        Set<String> choices = new LinkedHashSet<>();
        choices.add("Black");
        choices.add("Red");
        manaChoice.setChoices(choices);
        manaChoice.setMessage("Select black or red mana to add");
        Mana mana = new Mana();
        if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
            return false;
        }
        if (manaChoice.getChoice() == null) {
            return false;
        }
        switch(manaChoice.getChoice()) {
            case "Black":
                mana.increaseBlack();
                break;
            case "Red":
                mana.increaseRed();
                break;
        }
        controller.getManaPool().addMana(mana, game, source);
        return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) Choice(mage.choices.Choice) Mana(mage.Mana) ChoiceImpl(mage.choices.ChoiceImpl)

Example 59 with Mana

use of mage.Mana in project mage by magefree.

the class OrcishLumberjackManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        Choice manaChoice = new ChoiceImpl();
        Set<String> choices = new LinkedHashSet<>();
        choices.add("Red");
        choices.add("Green");
        manaChoice.setChoices(choices);
        manaChoice.setMessage("Select color of mana to add");
        for (int i = 0; i < 3; i++) {
            if (!player.choose(Outcome.Benefit, manaChoice, game)) {
                return mana;
            }
            switch(manaChoice.getChoice()) {
                case "Green":
                    mana.increaseGreen();
                    break;
                case "Red":
                    mana.increaseRed();
                    break;
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) ChoiceImpl(mage.choices.ChoiceImpl)

Example 60 with Mana

use of mage.Mana in project mage by magefree.

the class RousingRefrainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player player = game.getPlayer(source.getFirstTarget());
    if (controller == null || player == null || player.getHand().isEmpty()) {
        return false;
    }
    controller.getManaPool().addMana(new Mana(ManaType.RED, player.getHand().size()), 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