Search in sources :

Example 56 with Choice

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

the class DistantMelodyEffect method apply.

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

Example 57 with Choice

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

the class ExtinctionEffect 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 && sourceObject != null) {
        Choice typeChoice = new ChoiceCreatureType(sourceObject);
        if (player.choose(outcome, typeChoice, game)) {
            game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
            FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
            filterCreaturePermanent.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
            for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
                creature.destroy(source, game, true);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType)

Example 58 with Choice

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

the class GabrielAngelfireGainAbilityEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose one");
        choice.setChoices(choices);
        if (controller.choose(outcome, choice, game)) {
            switch(choice.getChoice()) {
                case "First strike":
                    ability = FirstStrikeAbility.getInstance();
                    break;
                case "Trample":
                    ability = TrampleAbility.getInstance();
                    break;
                case "Rampage 3":
                    ability = new RampageAbility(3);
                    break;
                default:
                    ability = FlyingAbility.getInstance();
                    break;
            }
        } else {
            discard();
        }
    }
}
Also used : Player(mage.players.Player) RampageAbility(mage.abilities.keyword.RampageAbility) Choice(mage.choices.Choice) ChoiceImpl(mage.choices.ChoiceImpl)

Example 59 with Choice

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

the class HarshMercyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller != null && sourceObject != null) {
        Set<String> chosenTypes = new HashSet<>();
        PlayerIteration: for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            Choice typeChoice = new ChoiceCreatureType(sourceObject);
            if (player != null && !player.choose(Outcome.DestroyPermanent, typeChoice, game)) {
                continue PlayerIteration;
            }
            String chosenType = typeChoice.getChoice();
            if (chosenType != null) {
                game.informPlayers(sourceObject.getIdName() + ": " + player.getLogName() + " has chosen " + chosenType);
                chosenTypes.add(chosenType);
            }
        }
        FilterPermanent filter = new FilterCreaturePermanent("creatures");
        for (String type : chosenTypes) {
            filter.add(Predicates.not(SubType.byDescription(type).getPredicate()));
        }
        return new DestroyAllEffect(filter, true).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) UUID(java.util.UUID) HashSet(java.util.HashSet) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 60 with Choice

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

the class JodahsAvengerEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceImpl(true);
        choice.setMessage("Choose one");
        choice.setChoices(choices);
        if (controller.choose(outcome, choice, game)) {
            switch(choice.getChoice()) {
                case "Double strike":
                    gainedAbility = DoubleStrikeAbility.getInstance();
                    break;
                case "Vigilance":
                    gainedAbility = VigilanceAbility.getInstance();
                    break;
                case "Shadow":
                    gainedAbility = ShadowAbility.getInstance();
                    break;
                default:
                    gainedAbility = ProtectionAbility.from(ObjectColor.RED);
                    break;
            }
        } else {
            discard();
        }
    }
}
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