Search in sources :

Example 46 with ChoiceImpl

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

the class FlowstoneSculptureEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose ability to add");
        choice.setChoices(choices);
        if (!controller.choose(outcome, choice, game)) {
            return false;
        }
        String chosen = choice.getChoice();
        if (chosen.equals("+1/+1 counter")) {
            return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
        } else {
            Ability gainedAbility;
            switch(chosen) {
                case "Flying":
                    gainedAbility = FlyingAbility.getInstance();
                    break;
                case "First strike":
                    gainedAbility = FirstStrikeAbility.getInstance();
                    break;
                default:
                    gainedAbility = TrampleAbility.getInstance();
                    break;
            }
            game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.WhileOnBattlefield), source);
            return true;
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) FirstStrikeAbility(mage.abilities.keyword.FirstStrikeAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TrampleAbility(mage.abilities.keyword.TrampleAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Example 47 with ChoiceImpl

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

the class FluctuatorEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    Player controller = game.getPlayer(abilityToModify.getControllerId());
    if (controller != null) {
        Mana mana = abilityToModify.getManaCostsToPay().getMana();
        int reduceMax = mana.getGeneric();
        if (reduceMax > 2) {
            reduceMax = 2;
        }
        if (reduceMax > 0) {
            int reduce;
            if (game.inCheckPlayableState() || controller.isComputer()) {
                reduce = reduceMax;
            } else {
                ChoiceImpl choice = new ChoiceImpl(true);
                Set<String> set = new LinkedHashSet<>();
                for (int i = 0; i <= reduceMax; i++) {
                    set.add(String.valueOf(i));
                }
                choice.setChoices(set);
                choice.setMessage("Reduce cycling cost");
                if (controller.choose(Outcome.Benefit, choice, game)) {
                    reduce = Integer.parseInt(choice.getChoice());
                } else {
                    return false;
                }
            }
            CardUtil.reduceCost(abilityToModify, reduce);
        }
        return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) Mana(mage.Mana) ChoiceImpl(mage.choices.ChoiceImpl)

Example 48 with ChoiceImpl

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

the class InvokeTheAncientsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    token.putOntoBattlefield(2, game, source, source.getControllerId());
    for (UUID tokenId : token.getLastAddedTokenIds()) {
        Permanent permanent = game.getPermanent(tokenId);
        if (permanent == null) {
            continue;
        }
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose vigilance, reach, or trample counter");
        choice.setChoices(choices);
        player.choose(outcome, choice, game);
        String chosen = choice.getChoice();
        if (chosen != null) {
            permanent.addCounters(CounterType.findByName(chosen.toLowerCase(Locale.ENGLISH)).createInstance(), source.getControllerId(), source, game);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) ChoiceImpl(mage.choices.ChoiceImpl) UUID(java.util.UUID)

Example 49 with ChoiceImpl

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

the class LunarAvengerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose ability to add");
        choice.setChoices(choices);
        if (!controller.choose(outcome, choice, game)) {
            return false;
        }
        Ability gainedAbility;
        String chosen = choice.getChoice();
        switch(chosen) {
            case "Flying":
                gainedAbility = FlyingAbility.getInstance();
                break;
            case "First strike":
                gainedAbility = FirstStrikeAbility.getInstance();
                break;
            default:
                gainedAbility = HasteAbility.getInstance();
                break;
        }
        game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn), source);
        return true;
    }
    return false;
}
Also used : HasteAbility(mage.abilities.keyword.HasteAbility) FirstStrikeAbility(mage.abilities.keyword.FirstStrikeAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) SunburstAbility(mage.abilities.keyword.SunburstAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Example 50 with ChoiceImpl

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

the class PemminsAuraBoostEnchantedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent enchantment = game.getPermanent(source.getSourceId());
    if (controller == null || enchantment == null) {
        return false;
    }
    Permanent creature = game.getPermanent(enchantment.getAttachedTo());
    if (creature == null) {
        return false;
    }
    Choice choice = new ChoiceImpl(true);
    choice.setMessage("Select how to boost");
    choice.getChoices().add(CHOICE_1);
    choice.getChoices().add(CHOICE_2);
    if (controller.choose(outcome, choice, game)) {
        if (choice.getChoice().equals(CHOICE_1)) {
            game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source);
        } else {
            game.addEffect(new BoostEnchantedEffect(-1, +1, Duration.EndOfTurn), source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) BoostEnchantedEffect(mage.abilities.effects.common.continuous.BoostEnchantedEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Aggregations

ChoiceImpl (mage.choices.ChoiceImpl)84 Player (mage.players.Player)80 Choice (mage.choices.Choice)67 Permanent (mage.game.permanent.Permanent)39 HashSet (java.util.HashSet)23 MageObject (mage.MageObject)16 Mana (mage.Mana)14 Card (mage.cards.Card)13 Ability (mage.abilities.Ability)11 LinkedHashSet (java.util.LinkedHashSet)10 Counter (mage.counters.Counter)10 UUID (java.util.UUID)8 TargetPermanent (mage.target.TargetPermanent)8 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)7 CardType (mage.constants.CardType)7 FlyingAbility (mage.abilities.keyword.FlyingAbility)6 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)6 ContinuousEffect (mage.abilities.effects.ContinuousEffect)5 GainAbilitySourceEffect (mage.abilities.effects.common.continuous.GainAbilitySourceEffect)5 FilterPermanent (mage.filter.FilterPermanent)5