Search in sources :

Example 71 with Choice

use of mage.choices.Choice 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 72 with Choice

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

the class NakedSingularityEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    TappedForManaEvent manaEvent = (TappedForManaEvent) event;
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = manaEvent.getPermanent();
    if (controller == null || permanent == null) {
        return false;
    }
    Choice choice = new ChoiceColor(true);
    choice.getChoices().clear();
    choice.setMessage("Pick a color to produce");
    if (permanent.hasSubtype(SubType.PLAINS, game)) {
        choice.getChoices().add("Red");
    }
    if (permanent.hasSubtype(SubType.ISLAND, game)) {
        choice.getChoices().add("Green");
    }
    if (permanent.hasSubtype(SubType.SWAMP, game)) {
        choice.getChoices().add("White");
    }
    if (permanent.hasSubtype(SubType.MOUNTAIN, game)) {
        choice.getChoices().add("Blue");
    }
    if (permanent.hasSubtype(SubType.FOREST, game)) {
        choice.getChoices().add("Black");
    }
    String chosenColor;
    if (choice.getChoices().size() == 1) {
        chosenColor = choice.getChoices().iterator().next();
    } else {
        controller.choose(Outcome.PutManaInPool, choice, game);
        chosenColor = choice.getChoice();
    }
    if (chosenColor == null) {
        return false;
    }
    Mana mana = manaEvent.getMana();
    int amount = mana.count();
    switch(chosenColor) {
        case "White":
            mana.setToMana(Mana.WhiteMana(amount));
            break;
        case "Blue":
            mana.setToMana(Mana.BlueMana(amount));
            break;
        case "Black":
            mana.setToMana(Mana.BlackMana(amount));
            break;
        case "Red":
            mana.setToMana(Mana.RedMana(amount));
            break;
        case "Green":
            mana.setToMana(Mana.GreenMana(amount));
            break;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 73 with Choice

use of mage.choices.Choice 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)

Example 74 with Choice

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

the class RoarOfTheCrowdEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
        if (!player.choose(Outcome.LoseLife, typeChoice, game)) {
            return false;
        }
        FilterControlledPermanent filter = new FilterControlledPermanent();
        filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        return new DamageTargetEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceCreatureType(mage.choices.ChoiceCreatureType) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 75 with Choice

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

the class ShiftingCeratopsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Choice choice = new ChoiceImpl(true);
    choice.setMessage("Choose an ability");
    choice.setChoices(choices);
    if (!player.choose(outcome, choice, game)) {
        return false;
    }
    Ability ability = null;
    switch(choice.getChoice()) {
        case "Reach":
            ability = ReachAbility.getInstance();
            break;
        case "Trample":
            ability = TrampleAbility.getInstance();
            break;
        case "Haste":
            ability = HasteAbility.getInstance();
            break;
    }
    if (ability != null) {
        game.addEffect(new GainAbilitySourceEffect(ability, Duration.EndOfTurn), source);
    }
    return true;
}
Also used : HasteAbility(mage.abilities.keyword.HasteAbility) CantBeCounteredSourceAbility(mage.abilities.common.CantBeCounteredSourceAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ReachAbility(mage.abilities.keyword.ReachAbility) TrampleAbility(mage.abilities.keyword.TrampleAbility) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect) 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