Search in sources :

Example 6 with ChoiceCreatureType

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

the class KindredDominanceEffect 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, typeChoice, game)) {
        game.informPlayers(controller.getLogName() + " has chosen " + typeChoice.getChoice());
        FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures not of the chosen type");
        filter.add(Predicates.not(SubType.byDescription(typeChoice.getChoice()).getPredicate()));
        return new DestroyAllEffect(filter).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 7 with ChoiceCreatureType

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

the class ChangeCreatureTypeTargetEffect method init.

@Override
public void init(Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return;
    }
    if (fromSubType == null) {
        Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
        typeChoice.setMessage("Choose creature type to change to Vampire");
        if (!controller.choose(outcome, typeChoice, game)) {
            discard();
            return;
        }
        fromSubType = SubType.byDescription(typeChoice.getChoice());
        if (!game.isSimulation()) {
            game.informPlayers(controller.getLogName() + " has chosen the creature type: " + fromSubType.toString());
        }
    }
    // To change body of generated methods, choose Tools | Templates.
    super.init(source, game);
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceCreatureType(mage.choices.ChoiceCreatureType)

Example 8 with ChoiceCreatureType

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

the class WalkingDesecrationEffect 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) {
        if (sourceObject != null) {
            Choice typeChoice = new ChoiceCreatureType(sourceObject);
            if (player.choose(outcome, typeChoice, game)) {
                game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
                FilterCreaturePermanent filter = new FilterCreaturePermanent();
                filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
                RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
                game.addEffect(effect, source);
                return true;
            }
        }
    }
    return false;
}
Also used : RequirementEffect(mage.abilities.effects.RequirementEffect) Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)

Example 9 with ChoiceCreatureType

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

the class BloodlineShamanEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    Choice typeChoice = new ChoiceCreatureType(sourceObject);
    if (controller != null && sourceObject != null && controller.choose(outcome, typeChoice, game)) {
        game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
        FilterCard filterSubtype = new FilterCard();
        filterSubtype.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        // Reveal the top card of your library.
        if (controller.getLibrary().hasCards()) {
            Card card = controller.getLibrary().getFromTop(game);
            Cards cards = new CardsImpl(card);
            controller.revealCards(sourceObject.getIdName(), cards, game);
            if (card != null) {
                // If that card is a creature card of the chosen type, put it into your hand.
                if (filterSubtype.match(card, game)) {
                    controller.moveCards(card, Zone.HAND, source, game);
                // Otherwise, put it into your graveyard.
                } else {
                    controller.moveCards(card, Zone.GRAVEYARD, source, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Choice(mage.choices.Choice) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) FilterCard(mage.filter.FilterCard)

Example 10 with ChoiceCreatureType

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

Aggregations

ChoiceCreatureType (mage.choices.ChoiceCreatureType)29 Player (mage.players.Player)29 Choice (mage.choices.Choice)28 MageObject (mage.MageObject)15 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)13 Permanent (mage.game.permanent.Permanent)9 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)5 FixedTarget (mage.target.targetpointer.FixedTarget)5 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)4 FilterCard (mage.filter.FilterCard)4 UUID (java.util.UUID)3 Card (mage.cards.Card)3 CardsImpl (mage.cards.CardsImpl)3 FilterPermanent (mage.filter.FilterPermanent)3 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)3 FilterCreatureCard (mage.filter.common.FilterCreatureCard)3 HashSet (java.util.HashSet)2 DestroyAllEffect (mage.abilities.effects.common.DestroyAllEffect)2 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)2