Search in sources :

Example 36 with ChoiceColor

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

the class AnyColorPermanentTypesManaEffect 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.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 (!onlyColors && 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");
        if (!onlyColors) {
            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.choose(outcome, choice, game)) {
                return mana;
            }
        }
        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;
                case "Colorless":
                    mana.setColorless(1);
                    break;
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) ChoiceColor(mage.choices.ChoiceColor)

Example 37 with ChoiceColor

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

the class ProtectionChosenColorTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (targetCreature != null) {
        Player player = game.getPlayer(targetCreature.getControllerId());
        if (player != null) {
            ChoiceColor colorChoice = new ChoiceColor();
            if (player.choose(Outcome.Neutral, colorChoice, game)) {
                game.informPlayers(targetCreature.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice());
                game.getState().setValue(targetCreature.getId() + "_color", colorChoice.getColor());
                ObjectColor protectColor = (ObjectColor) game.getState().getValue(targetCreature.getId() + "_color");
                if (protectColor != null) {
                    ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
                    effect.setTargetPointer(new FixedTarget(targetCreature, game));
                    game.addEffect(effect, source);
                }
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ObjectColor(mage.ObjectColor) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 38 with ChoiceColor

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

the class PrismaticBoonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ChoiceColor choice = new ChoiceColor();
    if (!player.choose(outcome, choice, game)) {
        return false;
    }
    game.addEffect(new GainAbilityTargetEffect(ProtectionAbility.from(choice.getColor()), Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 39 with ChoiceColor

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

the class PrismaticStrandsPreventionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        ChoiceColor choice = new ChoiceColor();
        controller.choose(Outcome.PreventDamage, choice, game);
        if (choice.isChosen()) {
            if (!game.isSimulation()) {
                game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen sources of the color " + choice.getChoice());
            }
            game.addEffect(new PrismaticStrandsPreventionEffect(choice.getColor()), source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) ChoiceColor(mage.choices.ChoiceColor)

Example 40 with ChoiceColor

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

the class StadiumVendorsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    TargetPlayer target = new TargetPlayer(1, 1, true);
    if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
        Player player = game.getPlayer(target.getFirstTarget());
        ChoiceColor colorChoice = new ChoiceColor(true);
        if (player == null || !player.choose(Outcome.Benefit, colorChoice, game)) {
            return false;
        }
        Effect effect = new AddManaToManaPoolTargetControllerEffect(colorChoice.getMana(2), "that player's");
        effect.setTargetPointer(new FixedTarget(player.getId(), game));
        return effect.apply(game, source);
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) AddManaToManaPoolTargetControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) AddManaToManaPoolTargetControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect) Effect(mage.abilities.effects.Effect) ChoiceColor(mage.choices.ChoiceColor) TargetPlayer(mage.target.TargetPlayer)

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