Search in sources :

Example 11 with ChoiceColor

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

the class HallOfGemstoneEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    Permanent mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (player == null || mageObject == null) {
        return;
    }
    ChoiceColor choice = new ChoiceColor();
    if (!player.choose(outcome, choice, game)) {
        discard();
        return;
    }
    game.informPlayers(mageObject.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice());
    game.getState().setValue(mageObject.getId() + "_color", choice.getColor());
    mageObject.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + choice.getChoice()), game);
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor)

Example 12 with ChoiceColor

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

the class OonaQueenOfTheFaeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
    ChoiceColor choice = new ChoiceColor();
    if (controller == null || opponent == null || !controller.choose(outcome, choice, game)) {
        return false;
    }
    int cardsWithColor = 0;
    Cards cardsToExile = new CardsImpl();
    cardsToExile.addAll(opponent.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
    for (Card card : cardsToExile.getCards(game)) {
        if (card != null && card.getColor(game).contains(choice.getColor())) {
            cardsWithColor++;
        }
    }
    controller.moveCards(cardsToExile, Zone.EXILED, source, game);
    if (cardsWithColor > 0) {
        new CreateTokenEffect(new OonaQueenFaerieRogueToken(), cardsWithColor).apply(game, source);
    }
    game.informPlayers("Oona: " + cardsWithColor + " Token" + (cardsWithColor != 1 ? "s" : "") + " created");
    return true;
}
Also used : Player(mage.players.Player) OonaQueenFaerieRogueToken(mage.game.permanent.token.OonaQueenFaerieRogueToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 13 with ChoiceColor

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

the class AddManaAnyColorAttachedControllerEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    if (game != null) {
        Permanent enchantment = game.getPermanent(source.getSourceId());
        if (enchantment != null) {
            Permanent land = game.getPermanent(enchantment.getAttachedTo());
            if (land != null) {
                Player player = game.getPlayer(land.getControllerId());
                ChoiceColor choice = new ChoiceColor();
                if (player != null && player.choose(outcome, choice, game)) {
                    return choice.getMana(1);
                }
            }
        }
    }
    return new Mana();
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor)

Example 14 with ChoiceColor

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

the class AddManaOfAnyTypeProducedEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana newMana = new Mana();
    if (game == null) {
        return newMana;
    }
    Permanent permanent = (Permanent) this.getValue("tappedPermanent");
    Mana types = (Mana) this.getValue("mana");
    if (permanent == null || types == null) {
        return newMana;
    }
    Player targetController = game.getPlayer(permanent.getControllerId());
    if (targetController == null) {
        return newMana;
    }
    Choice choice = new ChoiceColor(true);
    choice.getChoices().clear();
    choice.setMessage("Pick the type of mana to produce");
    if (types.getWhite() > 0) {
        choice.getChoices().add("White");
    }
    if (types.getBlue() > 0) {
        choice.getChoices().add("Blue");
    }
    if (types.getBlack() > 0) {
        choice.getChoices().add("Black");
    }
    if (types.getRed() > 0) {
        choice.getChoices().add("Red");
    }
    if (types.getGreen() > 0) {
        choice.getChoices().add("Green");
    }
    if (types.getColorless() > 0) {
        choice.getChoices().add("Colorless");
    }
    if (choice.getChoices().isEmpty()) {
        return newMana;
    }
    if (choice.getChoices().size() != 1 && !targetController.choose(outcome, choice, game)) {
        return newMana;
    }
    choice.setChoice(choice.getChoices().iterator().next());
    switch(choice.getChoice()) {
        case "White":
            newMana.setWhite(1);
            break;
        case "Blue":
            newMana.setBlue(1);
            break;
        case "Black":
            newMana.setBlack(1);
            break;
        case "Red":
            newMana.setRed(1);
            break;
        case "Green":
            newMana.setGreen(1);
            break;
        case "Colorless":
            newMana.setColorless(1);
            break;
    }
    return newMana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor)

Example 15 with ChoiceColor

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

the class AddManaOfAnyColorEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    if (game != null) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            String mes = String.format("Select a color of mana to add %d of it", this.amount);
            if (mes != null) {
                ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source.getSourceId()));
                if (controller.choose(outcome, choice, game)) {
                    if (choice.getColor() != null) {
                        Mana mana = choice.getMana(amount);
                        mana.setFlag(setFlag);
                        return mana;
                    }
                }
            }
        }
    }
    return new Mana();
}
Also used : Player(mage.players.Player) Mana(mage.Mana) 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