Search in sources :

Example 6 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class FoodChainManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int manaCostExiled = 0;
        for (Cost cost : source.getCosts()) {
            if (cost.isPaid() && cost instanceof ExileTargetCost) {
                for (Card card : ((ExileTargetCost) cost).getPermanents()) {
                    manaCostExiled += card.getManaValue();
                }
            }
        }
        ChoiceColor choice = new ChoiceColor();
        if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
            return mana;
        }
        Mana chosen = choice.getMana(manaCostExiled + 1);
        return manaBuilder.setMana(chosen, source, game).build();
    }
    return mana;
}
Also used : Player(mage.players.Player) ExileTargetCost(mage.abilities.costs.common.ExileTargetCost) CreatureCastConditionalMana(mage.abilities.mana.conditional.CreatureCastConditionalMana) ConditionalMana(mage.ConditionalMana) Mana(mage.Mana) ChoiceColor(mage.choices.ChoiceColor) Cost(mage.abilities.costs.Cost) ExileTargetCost(mage.abilities.costs.common.ExileTargetCost) Card(mage.cards.Card)

Example 7 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class MeteorCraterEffect method produceMana.

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

Example 8 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class NyxLotusDynamicManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return mana;
    }
    ChoiceColor choice = new ChoiceColor();
    choice.setMessage("Choose a color for devotion of Nyx Lotus");
    if (!controller.choose(outcome, choice, game)) {
        return mana;
    }
    return computeMana(choice.getChoice(), game, source);
}
Also used : Player(mage.players.Player) Mana(mage.Mana) ChoiceColor(mage.choices.ChoiceColor)

Example 9 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class NykthosDynamicManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return mana;
    }
    ChoiceColor choice = new ChoiceColor();
    choice.setMessage("Choose a color for devotion of Nykthos");
    if (!controller.choose(outcome, choice, game)) {
        return mana;
    }
    return computeMana(choice.getChoice(), game, source);
}
Also used : Player(mage.players.Player) Mana(mage.Mana) ChoiceColor(mage.choices.ChoiceColor)

Example 10 with ChoiceColor

use of mage.choices.ChoiceColor in project mage by magefree.

the class TrevaTheRenewerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    if (controller.choose(outcome, choice, game)) {
        game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ColorPredicate(choice.getColor()));
        int cardsWithColor = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game);
        if (cardsWithColor > 0) {
            new GainLifeEffect(cardsWithColor).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) ChoiceColor(mage.choices.ChoiceColor) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Aggregations

ChoiceColor (mage.choices.ChoiceColor)54 Player (mage.players.Player)52 Mana (mage.Mana)22 Permanent (mage.game.permanent.Permanent)17 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)14 Choice (mage.choices.Choice)10 ObjectColor (mage.ObjectColor)8 FilterCard (mage.filter.FilterCard)7 MageObject (mage.MageObject)5 FilterPermanent (mage.filter.FilterPermanent)5 FixedTarget (mage.target.targetpointer.FixedTarget)5 ConditionalMana (mage.ConditionalMana)4 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)4 Ability (mage.abilities.Ability)3 ProtectionAbility (mage.abilities.keyword.ProtectionAbility)3 Card (mage.cards.Card)3 TargetPlayer (mage.target.TargetPlayer)3 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)3 ArrayList (java.util.ArrayList)2