Search in sources :

Example 26 with ChoiceColor

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

the class BecomesColorOrColorsTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent target = game.getPermanent(source.getFirstTarget());
    StringBuilder sb = new StringBuilder();
    if (controller != null && target != null) {
        for (int i = 0; i < 5; i++) {
            if (i > 0) {
                if (!controller.chooseUse(Outcome.Neutral, "Choose another color?", source, game)) {
                    break;
                }
            }
            ChoiceColor choiceColor = new ChoiceColor();
            if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
                return false;
            }
            if (!game.isSimulation()) {
                game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + choiceColor.getChoice());
            }
            if (choiceColor.getColor().isBlack()) {
                sb.append('B');
            } else if (choiceColor.getColor().isBlue()) {
                sb.append('U');
            } else if (choiceColor.getColor().isRed()) {
                sb.append('R');
            } else if (choiceColor.getColor().isGreen()) {
                sb.append('G');
            } else if (choiceColor.getColor().isWhite()) {
                sb.append('W');
            }
        }
        String colors = new String(sb);
        ObjectColor chosenColors = new ObjectColor(colors);
        ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, duration);
        effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), 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) ObjectColor(mage.ObjectColor) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 27 with ChoiceColor

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

the class CouncilGuardianVote method playerChoose.

@Override
public String playerChoose(String voteInfo, Player player, Player decidingPlayer, Ability source, Game game) {
    ChoiceColor choice = new ChoiceColor();
    choice.getChoices().remove("White");
    choice.setSubMessage(voteInfo);
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    decidingPlayer.choose(Outcome.AIDontUseIt, choice, game);
    return choice.getChoice();
}
Also used : ChoiceColor(mage.choices.ChoiceColor)

Example 28 with ChoiceColor

use of mage.choices.ChoiceColor 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 29 with ChoiceColor

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

the class SearingRaysEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChoiceColor choice = new ChoiceColor();
    if (controller != null && controller.choose(outcome, choice, game) && choice.getColor() != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent(choice.getColor().getDescription() + " creatures");
        filter.add(new ColorPredicate(choice.getColor()));
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            int amount = game.getBattlefield().countAll(filter, playerId, game);
            if (amount > 0) {
                Player player = game.getPlayer(playerId);
                if (player != null) {
                    player.damage(amount, source.getSourceId(), source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ChoiceColor(mage.choices.ChoiceColor) UUID(java.util.UUID)

Example 30 with ChoiceColor

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

the class ZombieBoaTriggeredAbility 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)) {
        ObjectColor color = choice.getColor();
        game.informPlayers(player.getLogName() + " chooses " + color);
        game.addDelayedTriggeredAbility(new ZombieBoaTriggeredAbility(color), source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ObjectColor(mage.ObjectColor) 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