Search in sources :

Example 21 with ChoiceCreatureType

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

the class PacksDisdainEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
    if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) {
        FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
        filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1);
        ContinuousEffect effect = new BoostTargetEffect(negativePermanentsCount, negativePermanentsCount, Duration.EndOfTurn, true);
        effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Choice(mage.choices.Choice) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) ContinuousEffect(mage.abilities.effects.ContinuousEffect) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 22 with ChoiceCreatureType

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

the class RiptideShapeshifterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        Choice choice = new ChoiceCreatureType(sourceObject);
        if (!controller.choose(Outcome.BoostCreature, choice, game)) {
            return false;
        }
        Cards revealedCards = new CardsImpl();
        for (Card card : controller.getLibrary().getCards(game)) {
            if (card.isCreature(game) && card.hasSubtype(SubType.byDescription(choice.getChoice()), game)) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
                break;
            }
            revealedCards.add(card);
        }
        controller.revealCards(sourceObject.getIdName(), revealedCards, game);
        controller.moveCards(revealedCards, Zone.LIBRARY, source, game);
        controller.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType)

Example 23 with ChoiceCreatureType

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

the class RiptideChronologistEffect 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.untap(game);
            }
            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 24 with ChoiceCreatureType

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

the class MistformSliverEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (player != null && permanent != null) {
        Choice typeChoice = new ChoiceCreatureType(permanent);
        if (!player.choose(Outcome.Detriment, typeChoice, game)) {
            return false;
        }
        game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
        ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.byDescription(typeChoice.getChoice()), Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Choice(mage.choices.Choice) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) ContinuousEffect(mage.abilities.effects.ContinuousEffect) AddCardSubTypeTargetEffect(mage.abilities.effects.common.continuous.AddCardSubTypeTargetEffect)

Example 25 with ChoiceCreatureType

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

the class TribalUnityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject == null) {
        return false;
    }
    Player player = game.getPlayer(source.getControllerId());
    Choice typeChoice = new ChoiceCreatureType(sourceObject);
    if (player != null && player.choose(outcome, typeChoice, game)) {
        int boost = amount.calculate(game, source, this);
        if (typeChoice.getChoice() != null) {
            game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
        }
        FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
        filterCreaturePermanent.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
        game.addEffect(new BoostAllEffect(boost, boost, Duration.EndOfTurn, filterCreaturePermanent, false), source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

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