Search in sources :

Example 46 with Mana

use of mage.Mana in project mage by magefree.

the class ChromeMoxManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (permanent != null && player != null) {
        List<UUID> imprinted = permanent.getImprinted();
        if (imprinted != null && !imprinted.isEmpty()) {
            Card imprintedCard = game.getCard(imprinted.get(0));
            if (imprintedCard != null) {
                Choice choice = new ChoiceColor(true);
                choice.getChoices().clear();
                choice.setMessage("Pick a mana color");
                ObjectColor color = imprintedCard.getColor(game);
                if (color.isBlack()) {
                    choice.getChoices().add("Black");
                }
                if (color.isRed()) {
                    choice.getChoices().add("Red");
                }
                if (color.isBlue()) {
                    choice.getChoices().add("Blue");
                }
                if (color.isGreen()) {
                    choice.getChoices().add("Green");
                }
                if (color.isWhite()) {
                    choice.getChoices().add("White");
                }
                if (!choice.getChoices().isEmpty()) {
                    if (choice.getChoices().size() == 1) {
                        choice.setChoice(choice.getChoices().iterator().next());
                    } else {
                        if (!player.choose(outcome, choice, game)) {
                            return mana;
                        }
                    }
                    switch(choice.getChoice()) {
                        case "Black":
                            // player.getManaPool().addMana(Mana.BlackMana(1), game, source);
                            mana.add(Mana.BlackMana(1));
                            break;
                        case "Blue":
                            // player.getManaPool().addMana(Mana.BlueMana(1), game, source);
                            mana.add(Mana.BlueMana(1));
                            break;
                        case "Red":
                            // player.getManaPool().addMana(Mana.RedMana(1), game, source);
                            mana.add(Mana.RedMana(1));
                            break;
                        case "Green":
                            // player.getManaPool().addMana(Mana.GreenMana(1), game, source);
                            mana.add(Mana.GreenMana(1));
                            break;
                        case "White":
                            // player.getManaPool().addMana(Mana.WhiteMana(1), game, source);
                            mana.add(Mana.WhiteMana(1));
                            break;
                        default:
                            break;
                    }
                }
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID) ChoiceColor(mage.choices.ChoiceColor) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 47 with Mana

use of mage.Mana in project mage by magefree.

the class ConquerorsFlailEffect method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    Player controller = game.getPlayer(sourceAbility.getControllerId());
    int count = 0;
    if (controller != null) {
        Mana mana = new Mana();
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) {
            if (mana.getBlack() == 0 && permanent.getColor(game).isBlack()) {
                mana.increaseBlack();
                count++;
            }
            if (mana.getBlue() == 0 && permanent.getColor(game).isBlue()) {
                mana.increaseBlue();
                count++;
            }
            if (mana.getRed() == 0 && permanent.getColor(game).isRed()) {
                mana.increaseRed();
                count++;
            }
            if (mana.getGreen() == 0 && permanent.getColor(game).isGreen()) {
                mana.increaseGreen();
                count++;
            }
            if (mana.getWhite() == 0 && permanent.getColor(game).isWhite()) {
                mana.increaseWhite();
                count++;
            }
        }
    }
    return count;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent)

Example 48 with Mana

use of mage.Mana in project mage by magefree.

the class ContaminationReplacementEffect method replaceEvent.

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

Example 49 with Mana

use of mage.Mana in project mage by magefree.

the class EmpoweredAutogeneratorManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    game.getState().processAction(game);
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (sourcePermanent == null) {
        return mana;
    }
    sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source.getControllerId(), source, game);
    int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
    if (counters == 0) {
        return mana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return mana;
    }
    ChoiceColor choice = new ChoiceColor();
    choice.setMessage("Choose a color to add mana of that color");
    if (!controller.choose(outcome, choice, game)) {
        return mana;
    }
    if (choice.getChoice() == null) {
        return mana;
    }
    String color = choice.getChoice();
    switch(color) {
        case "Red":
            mana.setRed(counters);
            break;
        case "Blue":
            mana.setBlue(counters);
            break;
        case "White":
            mana.setWhite(counters);
            break;
        case "Black":
            mana.setBlack(counters);
            break;
        case "Green":
            mana.setGreen(counters);
            break;
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor)

Example 50 with Mana

use of mage.Mana in project mage by magefree.

the class RealityTwistEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    TappedForManaEvent manaEvent = (TappedForManaEvent) event;
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = manaEvent.getPermanent();
    if (controller == null || permanent == null) {
        return false;
    }
    Choice choice = new ChoiceColor(true);
    choice.getChoices().clear();
    choice.setMessage("Pick a color to produce");
    if (permanent.hasSubtype(SubType.PLAINS, game)) {
        choice.getChoices().add("Red");
    }
    if (permanent.hasSubtype(SubType.SWAMP, game)) {
        choice.getChoices().add("Green");
    }
    if (permanent.hasSubtype(SubType.MOUNTAIN, game)) {
        choice.getChoices().add("White");
    }
    if (permanent.hasSubtype(SubType.FOREST, game)) {
        choice.getChoices().add("Black");
    }
    String chosenColor;
    if (choice.getChoices().size() == 1) {
        chosenColor = choice.getChoices().iterator().next();
    } else {
        controller.choose(Outcome.PutManaInPool, choice, game);
        chosenColor = choice.getChoice();
    }
    if (chosenColor == null) {
        return false;
    }
    Mana mana = manaEvent.getMana();
    int amount = mana.count();
    switch(chosenColor) {
        case "White":
            mana.setToMana(Mana.WhiteMana(amount));
            break;
        case "Black":
            mana.setToMana(Mana.BlackMana(amount));
            break;
        case "Red":
            mana.setToMana(Mana.RedMana(amount));
            break;
        case "Green":
            mana.setToMana(Mana.GreenMana(amount));
            break;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor) TappedForManaEvent(mage.game.events.TappedForManaEvent)

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