Search in sources :

Example 11 with ChoiceCreatureType

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

the class BecomesChosenCreatureTypeTargetEffect 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";
        if (nonWall) {
            msg += " other than Wall";
        }
        typeChoice.setMessage(msg);
        if (nonWall) {
            typeChoice.getChoices().remove(SubType.WALL.getDescription());
        }
        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()) {
            // ADD TYPE TO TARGET
            ContinuousEffect effect = new BecomesCreatureTypeTargetEffect(duration, SubType.byDescription(chosenType));
            effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source), game));
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceCreatureType(mage.choices.ChoiceCreatureType) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card)

Example 12 with ChoiceCreatureType

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

the class GraveSifterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    typeChoice.setMessage("Choose creature type to return cards from your graveyard");
    Player controller = game.getPlayer(source.getControllerId());
    Set<Card> toHand = new HashSet<>();
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                typeChoice.clearChoice();
                if (player.choose(outcome, typeChoice, game)) {
                    game.informPlayers(player.getLogName() + " has chosen: " + typeChoice.getChoice());
                    FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice() + " from your graveyard");
                    filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
                    Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter);
                    player.chooseTarget(outcome, target, source, game);
                    toHand.addAll(new CardsImpl(target.getTargets()).getCards(game));
                }
            }
        }
        // must happen simultaneously Rule 101.4
        controller.moveCards(toHand, Zone.HAND, source, game, false, false, true, null);
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Target(mage.target.Target) Choice(mage.choices.Choice) ChoiceCreatureType(mage.choices.ChoiceCreatureType) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) UUID(java.util.UUID) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) HashSet(java.util.HashSet)

Example 13 with ChoiceCreatureType

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

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

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

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