Search in sources :

Example 31 with Choice

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

the class WalkingDesecrationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (player != null) {
        if (sourceObject != null) {
            Choice typeChoice = new ChoiceCreatureType(sourceObject);
            if (player.choose(outcome, typeChoice, game)) {
                game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
                FilterCreaturePermanent filter = new FilterCreaturePermanent();
                filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
                RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
                game.addEffect(effect, source);
                return true;
            }
        }
    }
    return false;
}
Also used : RequirementEffect(mage.abilities.effects.RequirementEffect) Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)

Example 32 with Choice

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

the class ConvokeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Spell spell = game.getStack().getSpell(source.getSourceId());
    if (controller != null && spell != null) {
        for (UUID creatureId : this.getTargetPointer().getTargets(game, source)) {
            Permanent perm = game.getPermanent(creatureId);
            if (perm == null) {
                continue;
            }
            String manaName;
            if (!perm.isTapped() && perm.tap(source, game)) {
                ManaPool manaPool = controller.getManaPool();
                Choice chooseManaType = buildChoice(perm.getColor(game), unpaid.getMana());
                if (!chooseManaType.getChoices().isEmpty()) {
                    if (chooseManaType.getChoices().size() > 1) {
                        chooseManaType.getChoices().add("Colorless");
                        chooseManaType.setMessage("Choose mana color to reduce from " + perm.getName());
                        if (!controller.choose(Outcome.Benefit, chooseManaType, game)) {
                            return false;
                        }
                    } else {
                        chooseManaType.setChoice(chooseManaType.getChoices().iterator().next());
                    }
                    if (chooseManaType.getChoice().equals("Black")) {
                        manaPool.addMana(Mana.BlackMana(1), game, source);
                        manaPool.unlockManaType(ManaType.BLACK);
                    }
                    if (chooseManaType.getChoice().equals("Blue")) {
                        manaPool.addMana(Mana.BlueMana(1), game, source);
                        manaPool.unlockManaType(ManaType.BLUE);
                    }
                    if (chooseManaType.getChoice().equals("Green")) {
                        manaPool.addMana(Mana.GreenMana(1), game, source);
                        manaPool.unlockManaType(ManaType.GREEN);
                    }
                    if (chooseManaType.getChoice().equals("White")) {
                        manaPool.addMana(Mana.WhiteMana(1), game, source);
                        manaPool.unlockManaType(ManaType.WHITE);
                    }
                    if (chooseManaType.getChoice().equals("Red")) {
                        manaPool.addMana(Mana.RedMana(1), game, source);
                        manaPool.unlockManaType(ManaType.RED);
                    }
                    if (chooseManaType.getChoice().equals("Colorless")) {
                        manaPool.addMana(Mana.ColorlessMana(1), game, source);
                        manaPool.unlockManaType(ManaType.COLORLESS);
                    }
                    manaName = chooseManaType.getChoice().toLowerCase(Locale.ENGLISH);
                } else {
                    manaPool.addMana(Mana.ColorlessMana(1), game, source);
                    manaPool.unlockManaType(ManaType.COLORLESS);
                    manaName = "colorless";
                }
                game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CONVOKED, perm.getId(), source, source.getControllerId()));
                game.informPlayers("Convoke: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay one " + manaName + " mana");
                // can't use mana abilities after that (convoke cost must be payed after mana abilities only)
                spell.setCurrentActivatingManaAbilitiesStep(ActivationManaAbilityStep.AFTER);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) ManaPool(mage.players.ManaPool) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Example 33 with Choice

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

the class BloodlineShamanEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    Choice typeChoice = new ChoiceCreatureType(sourceObject);
    if (controller != null && sourceObject != null && controller.choose(outcome, typeChoice, game)) {
        game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
        FilterCard filterSubtype = new FilterCard();
        filterSubtype.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        // Reveal the top card of your library.
        if (controller.getLibrary().hasCards()) {
            Card card = controller.getLibrary().getFromTop(game);
            Cards cards = new CardsImpl(card);
            controller.revealCards(sourceObject.getIdName(), cards, game);
            if (card != null) {
                // If that card is a creature card of the chosen type, put it into your hand.
                if (filterSubtype.match(card, game)) {
                    controller.moveCards(card, Zone.HAND, source, game);
                // Otherwise, put it into your graveyard.
                } else {
                    controller.moveCards(card, Zone.GRAVEYARD, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Choice(mage.choices.Choice) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) FilterCard(mage.filter.FilterCard)

Example 34 with Choice

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

the class ChromeMoxManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game == null) {
        return mana;
    }
    Permanent permanent = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (permanent != null && player != null) {
        List<UUID> imprinted = permanent.getImprinted();
        if (imprinted != null && !imprinted.isEmpty()) {
            Card imprintedCard = game.getCard(imprinted.get(0));
            if (imprintedCard != null) {
                Choice choice = new ChoiceColor(true);
                choice.getChoices().clear();
                choice.setMessage("Pick a mana color");
                ObjectColor color = imprintedCard.getColor(game);
                if (color.isBlack()) {
                    choice.getChoices().add("Black");
                }
                if (color.isRed()) {
                    choice.getChoices().add("Red");
                }
                if (color.isBlue()) {
                    choice.getChoices().add("Blue");
                }
                if (color.isGreen()) {
                    choice.getChoices().add("Green");
                }
                if (color.isWhite()) {
                    choice.getChoices().add("White");
                }
                if (!choice.getChoices().isEmpty()) {
                    if (choice.getChoices().size() == 1) {
                        choice.setChoice(choice.getChoices().iterator().next());
                    } else {
                        if (!player.choose(outcome, choice, game)) {
                            return mana;
                        }
                    }
                    switch(choice.getChoice()) {
                        case "Black":
                            // player.getManaPool().addMana(Mana.BlackMana(1), game, source);
                            mana.add(Mana.BlackMana(1));
                            break;
                        case "Blue":
                            // player.getManaPool().addMana(Mana.BlueMana(1), game, source);
                            mana.add(Mana.BlueMana(1));
                            break;
                        case "Red":
                            // player.getManaPool().addMana(Mana.RedMana(1), game, source);
                            mana.add(Mana.RedMana(1));
                            break;
                        case "Green":
                            // player.getManaPool().addMana(Mana.GreenMana(1), game, source);
                            mana.add(Mana.GreenMana(1));
                            break;
                        case "White":
                            // player.getManaPool().addMana(Mana.WhiteMana(1), game, source);
                            mana.add(Mana.WhiteMana(1));
                            break;
                        default:
                            break;
                    }
                }
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) UUID(java.util.UUID) ChoiceColor(mage.choices.ChoiceColor) TargetCard(mage.target.TargetCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 35 with Choice

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

the class FatespinnerSkipEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (player != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose phase or step to skip");
        choice.setChoices(choices);
        if (!player.choose(outcome, choice, game)) {
            return false;
        }
        String chosenPhase = choice.getChoice();
        game.informPlayers(player.getLogName() + " has chosen to skip " + chosenPhase.toLowerCase(Locale.ENGLISH) + '.');
        game.addEffect(new FatespinnerSkipEffect(chosenPhase), source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceImpl(mage.choices.ChoiceImpl)

Aggregations

Choice (mage.choices.Choice)117 Player (mage.players.Player)114 ChoiceImpl (mage.choices.ChoiceImpl)67 Permanent (mage.game.permanent.Permanent)51 ChoiceCreatureType (mage.choices.ChoiceCreatureType)28 MageObject (mage.MageObject)27 Mana (mage.Mana)22 HashSet (java.util.HashSet)21 Card (mage.cards.Card)17 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)16 UUID (java.util.UUID)15 ContinuousEffect (mage.abilities.effects.ContinuousEffect)13 FilterPermanent (mage.filter.FilterPermanent)12 Ability (mage.abilities.Ability)10 ChoiceColor (mage.choices.ChoiceColor)10 Counter (mage.counters.Counter)10 TargetPermanent (mage.target.TargetPermanent)10 FilterCard (mage.filter.FilterCard)8 FixedTarget (mage.target.targetpointer.FixedTarget)8 CardType (mage.constants.CardType)7