Search in sources :

Example 51 with ChoiceColor

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

the class AstralCornucopiaManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (sourcePermanent != null) {
        int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
        if (counters > 0) {
            Player controller = game.getPlayer(source.getControllerId());
            if (controller != null) {
                ChoiceColor choice = new ChoiceColor();
                choice.setMessage("Choose a color to add mana of that color");
                if (controller.choose(outcome, choice, game)) {
                    if (choice.getChoice() != null) {
                        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 52 with ChoiceColor

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

the class CoalitionRelicEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (sourcePermanent != null && player != null) {
        int chargeCounters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
        sourcePermanent.removeCounters(CounterType.CHARGE.createInstance(chargeCounters), source, game);
        Mana mana = new Mana();
        ChoiceColor choice = new ChoiceColor();
        for (int i = 0; i < chargeCounters; i++) {
            if (!player.choose(outcome, choice, game)) {
                return false;
            }
            choice.increaseMana(mana);
            choice.clearChoice();
        }
        player.getManaPool().addMana(mana, game, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor)

Example 53 with ChoiceColor

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

the class CarpetOfFlowersEffect 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());
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && controller.choose(Outcome.Benefit, choice, game)) {
        int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
        if (count > 0) {
            switch(choice.getChoice()) {
                case "Black":
                    mana.setBlack(count);
                    break;
                case "Blue":
                    mana.setBlue(count);
                    break;
                case "Red":
                    mana.setRed(count);
                    break;
                case "Green":
                    mana.setGreen(count);
                    break;
                case "White":
                    mana.setWhite(count);
                    break;
                default:
                    break;
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) ChoiceColor(mage.choices.ChoiceColor)

Example 54 with ChoiceColor

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

the class DarigaazTheIgniterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChoiceColor choice = new ChoiceColor(true);
    if (controller != null && controller.choose(outcome, choice, game)) {
        game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
        Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
        if (damagedPlayer != null) {
            damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game);
            FilterCard filter = new FilterCard();
            filter.add(new ColorPredicate(choice.getColor()));
            int damage = damagedPlayer.getHand().count(filter, source.getSourceId(), source.getControllerId(), game);
            if (damage > 0) {
                damagedPlayer.damage(damage, source.getSourceId(), source, game);
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) ChoiceColor(mage.choices.ChoiceColor)

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