Search in sources :

Example 96 with Choice

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

the class KatildaDawnhartPrimeManaEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    Mana mana = new Mana();
    if (game != null) {
        Player controller = game.getPlayer(source.getControllerId());
        Permanent permanent = source.getSourcePermanentIfItStillExists(game);
        if (controller != null && permanent != null) {
            Choice choice = new ChoiceImpl();
            choice.setMessage("Pick a mana color");
            ObjectColor color = permanent.getColor(game);
            if (color.isWhite()) {
                choice.getChoices().add("White");
            }
            if (color.isBlue()) {
                choice.getChoices().add("Blue");
            }
            if (color.isBlack()) {
                choice.getChoices().add("Black");
            }
            if (color.isRed()) {
                choice.getChoices().add("Red");
            }
            if (color.isGreen()) {
                choice.getChoices().add("Green");
            }
            if (!choice.getChoices().isEmpty()) {
                if (choice.getChoices().size() == 1) {
                    choice.setChoice(choice.getChoices().iterator().next());
                } else {
                    controller.choose(outcome, choice, game);
                }
                if (choice.getChoice() != null) {
                    switch(choice.getChoice()) {
                        case "White":
                            mana.setWhite(1);
                            break;
                        case "Blue":
                            mana.setBlue(1);
                            break;
                        case "Black":
                            mana.setBlack(1);
                            break;
                        case "Red":
                            mana.setRed(1);
                            break;
                        case "Green":
                            mana.setGreen(1);
                            break;
                    }
                }
            }
        }
    }
    return mana;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) ChoiceImpl(mage.choices.ChoiceImpl)

Example 97 with Choice

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

the class MistformSliverEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (player != null && permanent != null) {
        Choice typeChoice = new ChoiceCreatureType(permanent);
        if (!player.choose(Outcome.Detriment, typeChoice, game)) {
            return false;
        }
        game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
        ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.byDescription(typeChoice.getChoice()), Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCardSubTypeTargetEffect(mage.abilities.effects.common.continuous.AddCardSubTypeTargetEffect)

Example 98 with Choice

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

the class SasayasEssenceManaEffect method produceMana.

/**
 * RULINGS 6/1/2005 If Sasaya’s Essence’s controller has four Forests and
 * taps one of them for Green, the Essence will add GreenGreenGreen to that
 * player’s mana pool for a total of GreenGreenGreenGreen.
 *
 * 6/1/2005 If Sasaya’s Essence’s controller has four Mossfire Valley and
 * taps one of them for RedGreen, the Essence will add three mana (one for
 * each other Mossfire Valley) of any combination of Red and/or Green to
 * that player’s mana pool.
 *
 * 6/1/2005 If Sasaya’s Essence’s controller has two Brushlands and taps one
 * of them for White, Sasaya’s Essence adds another White to that player’s
 * mana pool. It won’t produce Green or Colorless unless the land was tapped
 * for Green or Colorless instead.
 */
@Override
public Mana produceMana(Game game, Ability source) {
    Mana newMana = new Mana();
    if (game == null) {
        return newMana;
    }
    Player controller = game.getPlayer(source.getControllerId());
    Mana mana = (Mana) this.getValue("mana");
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (controller != null && mana != null && permanent != null) {
        FilterPermanent filter = new FilterLandPermanent();
        filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
        filter.add(new NamePredicate(permanent.getName()));
        int count = game.getBattlefield().countAll(filter, controller.getId(), game);
        if (count > 0) {
            Choice choice = new ChoiceColor(true);
            choice.getChoices().clear();
            choice.setMessage("Pick the type of mana to produce");
            if (mana.getBlack() > 0) {
                choice.getChoices().add("Black");
            }
            if (mana.getRed() > 0) {
                choice.getChoices().add("Red");
            }
            if (mana.getBlue() > 0) {
                choice.getChoices().add("Blue");
            }
            if (mana.getGreen() > 0) {
                choice.getChoices().add("Green");
            }
            if (mana.getWhite() > 0) {
                choice.getChoices().add("White");
            }
            if (mana.getColorless() > 0) {
                choice.getChoices().add("Colorless");
            }
            if (!choice.getChoices().isEmpty()) {
                for (int i = 0; i < count; i++) {
                    choice.clearChoice();
                    if (choice.getChoices().size() == 1) {
                        choice.setChoice(choice.getChoices().iterator().next());
                    } else {
                        if (!controller.choose(outcome, choice, game)) {
                            return newMana;
                        }
                    }
                    switch(choice.getChoice()) {
                        case "Black":
                            newMana.increaseBlack();
                            break;
                        case "Blue":
                            newMana.increaseBlue();
                            break;
                        case "Red":
                            newMana.increaseRed();
                            break;
                        case "Green":
                            newMana.increaseGreen();
                            break;
                        case "White":
                            newMana.increaseWhite();
                            break;
                        case "Colorless":
                            newMana.increaseColorless();
                            break;
                    }
                }
            }
        }
    }
    return newMana;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Mana(mage.Mana) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) ChoiceColor(mage.choices.ChoiceColor)

Example 99 with Choice

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

the class StorageMatrixRestrictionEffect method applies.

@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
    if (game.getStep().getType() == PhaseStep.UNTAP) {
        if (game.getTurnNum() != turn) {
            turn = game.getTurnNum();
            applies = false;
            Permanent storageMatrix = game.getPermanent(source.getSourceId());
            if (storageMatrix != null && !storageMatrix.isTapped()) {
                Choice choiceImpl = new ChoiceImpl(true);
                choiceImpl.setMessage("Untap which kind of permanent?");
                choiceImpl.setChoices(choice);
                Player player = game.getPlayer(game.getActivePlayerId());
                if (player != null && player.choose(outcome, choiceImpl, game)) {
                    String choosenType = choiceImpl.getChoice();
                    if (choosenType != null) {
                        game.informPlayers(storageMatrix.getLogName() + ": " + player.getLogName() + " chose to untap " + choosenType);
                        if (choosenType.equals(CardType.ARTIFACT.toString())) {
                            type = CardType.ARTIFACT;
                        } else if (choosenType.equals(CardType.LAND.toString())) {
                            type = CardType.LAND;
                        } else {
                            type = CardType.CREATURE;
                        }
                        applies = true;
                    }
                }
            }
        }
        if (applies) {
            return !permanent.getCardType(game).contains(type);
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) ChoiceImpl(mage.choices.ChoiceImpl)

Example 100 with Choice

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

the class StingingStudyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Set<Integer> manaValues = new HashSet<>();
    for (Card commander : game.getCommanderCardsFromAnyZones(player, CommanderCardType.ANY, Zone.BATTLEFIELD, Zone.COMMAND)) {
        manaValues.add(commander.getManaValue());
    }
    int chosenValue;
    if (manaValues.size() > 1) {
        Choice choice = new ChoiceImpl(true);
        choice.setChoices(manaValues.stream().map(x -> "" + x).collect(Collectors.toSet()));
        player.choose(outcome, choice, game);
        chosenValue = Integer.parseInt(choice.getChoice());
    } else {
        chosenValue = manaValues.stream().findFirst().orElse(0);
    }
    if (chosenValue == 0) {
        return false;
    }
    player.drawCards(chosenValue, source, game);
    player.loseLife(chosenValue, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceImpl(mage.choices.ChoiceImpl) HashSet(java.util.HashSet) Card(mage.cards.Card)

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