Search in sources :

Example 36 with Choice

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

the class GideonBlackbladeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (player == null || permanent == null) {
        return false;
    }
    Choice choice = new ChoiceImpl(true);
    choice.setMessage("Choose an ability to give to " + permanent.getLogName());
    choice.setChoices(choices);
    if (!player.choose(outcome, choice, game)) {
        return false;
    }
    Ability ability = null;
    switch(choice.getChoice()) {
        case "Vigilance":
            ability = VigilanceAbility.getInstance();
            break;
        case "Lifelink":
            ability = LifelinkAbility.getInstance();
            break;
        case "Indestructible":
            ability = IndestructibleAbility.getInstance();
            break;
    }
    if (ability != null) {
        game.addEffect(new GainAbilityTargetEffect(ability, Duration.EndOfTurn), source);
    }
    return true;
}
Also used : IndestructibleAbility(mage.abilities.keyword.IndestructibleAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) LifelinkAbility(mage.abilities.keyword.LifelinkAbility) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) LoyaltyAbility(mage.abilities.LoyaltyAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) TargetNonlandPermanent(mage.target.common.TargetNonlandPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ChoiceImpl(mage.choices.ChoiceImpl)

Example 37 with Choice

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

the class BecomesChosenCreatureTypeControlledEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getSourceId());
    String chosenType = "";
    if (player != null && card != null) {
        Choice typeChoice = new ChoiceCreatureType();
        String msg = "Choose a creature type";
        typeChoice.setMessage(msg);
        while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
            if (!player.canRespond()) {
                return false;
            }
        }
        game.informPlayers(card.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
        chosenType = typeChoice.getChoice();
        if (chosenType != null && !chosenType.isEmpty()) {
            for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) {
                ContinuousEffect effect = new BecomesCreatureTypeTargetEffect(Duration.EndOfTurn, SubType.byDescription(chosenType));
                effect.setTargetPointer(new FixedTarget(permanent, game));
                game.addEffect(effect, source);
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BecomesCreatureTypeTargetEffect(mage.abilities.effects.common.continuous.BecomesCreatureTypeTargetEffect) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card)

Example 38 with Choice

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

the class RealityTwistEffect 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.SWAMP, game)) {
        choice.getChoices().add("Green");
    }
    if (permanent.hasSubtype(SubType.MOUNTAIN, game)) {
        choice.getChoices().add("White");
    }
    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 "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 39 with Choice

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

the class VisionCharmEffect 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 ChoiceLandType();
        if (!controller.choose(outcome, choice, game)) {
            discard();
            return;
        }
        targetLandType = choice.getChoice();
        choice = new ChoiceBasicLandType();
        if (!controller.choose(outcome, choice, game)) {
            discard();
            return;
        }
        targetBasicLandType = SubType.byDescription(choice.getChoice());
        if (targetLandType == null || targetBasicLandType == null) {
            this.discard();
            return;
        }
    } else {
        this.discard();
        return;
    }
    FilterPermanent filter = new FilterLandPermanent();
    filter.add(SubType.byDescription(targetLandType).getPredicate());
    if (this.affectedObjectsSet) {
        for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
            affectedObjectList.add(new MageObjectReference(permanent, game));
        }
    }
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceLandType(mage.choices.ChoiceLandType) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetArtifactPermanent(mage.target.common.TargetArtifactPermanent) Permanent(mage.game.permanent.Permanent) ChoiceBasicLandType(mage.choices.ChoiceBasicLandType) MageObjectReference(mage.MageObjectReference)

Example 40 with Choice

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

the class BecomesBasicLandTargetEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    // choose land type
    if (chooseLandType) {
        Player controller = game.getPlayer(source.getControllerId());
        Choice choice = new ChoiceBasicLandType();
        if (controller != null && controller.choose(outcome, choice, game)) {
            landTypes.add(SubType.byDescription(choice.getChoice()));
        } else {
            this.discard();
            return;
        }
    }
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceBasicLandType(mage.choices.ChoiceBasicLandType)

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