Search in sources :

Example 31 with ChoiceColor

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

the class ConvokeEffect method buildChoice.

private Choice buildChoice(ObjectColor creatureColor, Mana mana) {
    Choice choice = new ChoiceColor();
    choice.getChoices().clear();
    if (creatureColor.isBlack() && mana.getBlack() > 0) {
        choice.getChoices().add("Black");
    }
    if (creatureColor.isBlue() && mana.getBlue() > 0) {
        choice.getChoices().add("Blue");
    }
    if (creatureColor.isGreen() && mana.getGreen() > 0) {
        choice.getChoices().add("Green");
    }
    if (creatureColor.isRed() && mana.getRed() > 0) {
        choice.getChoices().add("Red");
    }
    if (creatureColor.isWhite() && mana.getWhite() > 0) {
        choice.getChoices().add("White");
    }
    return choice;
}
Also used : Choice(mage.choices.Choice) ChoiceColor(mage.choices.ChoiceColor)

Example 32 with ChoiceColor

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

the class BecomesColorOrColorsEnchantedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (enchantment == null) {
        return false;
    }
    Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
    StringBuilder sb = new StringBuilder();
    if (controller == null || permanent == null) {
        return false;
    }
    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(permanent.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.Custom);
    effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(effect, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) BecomesColorTargetEffect(mage.abilities.effects.common.continuous.BecomesColorTargetEffect) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ObjectColor(mage.ObjectColor) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 33 with ChoiceColor

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

the class NakedSingularityEffect 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.ISLAND, game)) {
        choice.getChoices().add("Green");
    }
    if (permanent.hasSubtype(SubType.SWAMP, game)) {
        choice.getChoices().add("White");
    }
    if (permanent.hasSubtype(SubType.MOUNTAIN, game)) {
        choice.getChoices().add("Blue");
    }
    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 "Blue":
            mana.setToMana(Mana.BlueMana(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)

Example 34 with ChoiceColor

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

the class PersecuteEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    ChoiceColor choice = new ChoiceColor();
    if (controller == null || sourceObject == null || targetPlayer == null || !controller.choose(outcome, choice, game)) {
        return false;
    }
    FilterCard filterCard = new FilterCard();
    filterCard.add(new ColorPredicate(choice.getColor()));
    targetPlayer.revealCards(source, targetPlayer.getHand(), game);
    targetPlayer.discard(new CardsImpl(targetPlayer.getHand().getCards(filterCard, game)), false, source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) MageObject(mage.MageObject) ChoiceColor(mage.choices.ChoiceColor) CardsImpl(mage.cards.CardsImpl)

Example 35 with ChoiceColor

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

the class RithTheAwakenerEffect 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 CreateTokenEffect(new SaprolingToken(), cardsWithColor).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) SaprolingToken(mage.game.permanent.token.SaprolingToken) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) 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