Search in sources :

Example 16 with Choice

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

the class ChooseModeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (sourcePermanent == null) {
        sourcePermanent = game.getPermanentEntering(source.getSourceId());
    }
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage(choiceMessage);
        choice.getChoices().addAll(modes);
        if (controller.choose(Outcome.Neutral, choice, game)) {
            if (!game.isSimulation()) {
                game.informPlayers(sourcePermanent.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
            }
            game.getState().setValue(source.getSourceId() + "_modeChoice", choice.getChoice());
            sourcePermanent.addInfo("_modeChoice", "<font color = 'blue'>Chosen mode: " + choice.getChoice() + "</font>", game);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) ChoiceImpl(mage.choices.ChoiceImpl)

Example 17 with Choice

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

the class ChooseCreatureTypeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getPermanentEntering(source.getSourceId());
    if (mageObject == null) {
        mageObject = game.getObject(source.getSourceId());
    }
    if (controller != null && mageObject != null) {
        Choice typeChoice = new ChoiceCreatureType(mageObject);
        if (controller.choose(outcome, typeChoice, game)) {
            if (!game.isSimulation()) {
                game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
            }
            game.getState().setValue(source.getSourceId() + "_type", SubType.byDescription(typeChoice.getChoice()));
            if (mageObject instanceof Permanent) {
                ((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType)

Example 18 with Choice

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

the class RemoveCounterTargetEffect method selectCounterType.

private Counter selectCounterType(Game game, Ability source, Permanent permanent) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !permanent.getCounters(game).isEmpty()) {
        String counterName = null;
        if (permanent.getCounters(game).size() > 1) {
            Choice choice = new ChoiceImpl(true);
            Set<String> choices = new HashSet<>();
            for (Counter counterOnPermanent : permanent.getCounters(game).values()) {
                if (permanent.getCounters(game).getCount(counterOnPermanent.getName()) > 0) {
                    choices.add(counterOnPermanent.getName());
                }
            }
            choice.setChoices(choices);
            choice.setMessage("Choose a counter type to remove from " + permanent.getName());
            if (controller.choose(Outcome.Detriment, choice, game)) {
                counterName = choice.getChoice();
            } else {
                return null;
            }
        } else {
            for (Counter counterOnPermanent : permanent.getCounters(game).values()) {
                if (counterOnPermanent.getCount() > 0) {
                    counterName = counterOnPermanent.getName();
                }
            }
        }
        return new Counter(counterName);
    }
    return null;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Counter(mage.counters.Counter) ChoiceImpl(mage.choices.ChoiceImpl) HashSet(java.util.HashSet)

Example 19 with Choice

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

the class NaturesBlessingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent targetPermanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
    if (controller != null && targetPermanent != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose one");
        choice.setChoices(choices);
        if (controller.choose(outcome, choice, game)) {
            switch(choice.getChoice()) {
                case "Banding":
                    gainedAbility = BandingAbility.getInstance();
                    break;
                case "First strike":
                    gainedAbility = FirstStrikeAbility.getInstance();
                    break;
                case "Trample":
                    gainedAbility = TrampleAbility.getInstance();
            }
        }
        if (gainedAbility != null) {
            game.addEffect(new GainAbilityTargetEffect(gainedAbility, Duration.Custom), source);
        } else {
            targetPermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
            game.informPlayers(controller.getLogName() + " puts a +1/+1 counter on " + targetPermanent.getLogName());
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Example 20 with Choice

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

the class SarkhanUnbrokenAbility1 method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        controller.drawCards(1, source, game);
        game.fireUpdatePlayersEvent();
        Choice manaChoice = new ChoiceImpl();
        Set<String> choices = new LinkedHashSet<>();
        choices.add("White");
        choices.add("Blue");
        choices.add("Black");
        choices.add("Red");
        choices.add("Green");
        manaChoice.setChoices(choices);
        manaChoice.setMessage("Select color of mana to add");
        Mana mana = new Mana();
        if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
            return false;
        }
        switch(manaChoice.getChoice()) {
            case "White":
                mana.increaseWhite();
                break;
            case "Blue":
                mana.increaseBlue();
                break;
            case "Black":
                mana.increaseBlack();
                break;
            case "Red":
                mana.increaseRed();
                break;
            case "Green":
                mana.increaseGreen();
                break;
        }
        controller.getManaPool().addMana(mana, game, source);
        return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) Choice(mage.choices.Choice) Mana(mage.Mana) 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