Search in sources :

Example 11 with FixedTarget

use of mage.target.targetpointer.FixedTarget in project mage by magefree.

the class DiffusionSliverTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
        return false;
    }
    Permanent creature = game.getPermanent(event.getTargetId());
    if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) {
        return false;
    }
    this.getEffects().clear();
    Effect effect = new CounterUnlessPaysEffect(new GenericManaCost(2));
    effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
    this.addEffect(effect);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Effect(mage.abilities.effects.Effect) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect)

Example 12 with FixedTarget

use of mage.target.targetpointer.FixedTarget in project mage by magefree.

the class DinOfTheFireherdEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean applied;
    Token token = new DinOfTheFireherdToken();
    applied = token.putOntoBattlefield(1, game, source, source.getControllerId());
    int blackCreaturesControllerControls = game.getBattlefield().countAll(blackCreatureFilter, source.getControllerId(), game);
    int redCreaturesControllerControls = game.getBattlefield().countAll(redCreatureFilter, source.getControllerId(), game);
    Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetOpponent != null) {
        Effect effect = new SacrificeEffect(new FilterControlledCreaturePermanent(), blackCreaturesControllerControls, "Target Opponent");
        effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect.apply(game, source);
        Effect effect2 = new SacrificeEffect(new FilterControlledLandPermanent(), redCreaturesControllerControls, "Target Opponent");
        effect2.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect2.apply(game, source);
        applied = true;
    }
    return applied;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) DinOfTheFireherdToken(mage.game.permanent.token.DinOfTheFireherdToken) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) DinOfTheFireherdToken(mage.game.permanent.token.DinOfTheFireherdToken) Token(mage.game.permanent.token.Token) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent)

Example 13 with FixedTarget

use of mage.target.targetpointer.FixedTarget in project mage by magefree.

the class DinosaurHunterAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getSourceId().equals(getSourceId())) {
        return false;
    }
    Permanent targetPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (targetPermanent == null || !targetPermanent.hasSubtype(SubType.DINOSAUR, game)) {
        return false;
    }
    getEffects().setTargetPointer(new FixedTarget(targetPermanent, game));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent)

Example 14 with FixedTarget

use of mage.target.targetpointer.FixedTarget in project mage by magefree.

the class DireFleetDaredevilReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
        if (targetCard != null) {
            if (controller.moveCards(targetCard, Zone.EXILED, source, game)) {
                targetCard = game.getCard(targetCard.getId());
                if (targetCard != null) {
                    // you may play and spend any mana
                    CardUtil.makeCardPlayable(game, source, targetCard, Duration.EndOfTurn, true);
                    // exile from graveyard
                    ContinuousEffect effect = new DireFleetDaredevilReplacementEffect();
                    effect.setTargetPointer(new FixedTarget(targetCard, game));
                    game.addEffect(effect, source);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 15 with FixedTarget

use of mage.target.targetpointer.FixedTarget in project mage by magefree.

the class ElkinLairPutIntoGraveyardEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (player != null && sourcePermanent != null) {
        Card[] cards = player.getHand().getCards(new FilterCard(), game).toArray(new Card[0]);
        if (cards.length > 0) {
            Card card = cards[RandomUtil.nextInt(cards.length)];
            if (card != null) {
                String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled";
                player.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName);
                if (game.getState().getZone(card.getId()) == Zone.EXILED) {
                    ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(card, game));
                    game.addEffect(effect, source);
                    DelayedTriggeredAbility delayed = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ElkinLairPutIntoGraveyardEffect());
                    game.addDelayedTriggeredAbility(delayed, source);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ContinuousEffect(mage.abilities.effects.ContinuousEffect) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Aggregations

FixedTarget (mage.target.targetpointer.FixedTarget)746 Permanent (mage.game.permanent.Permanent)491 Player (mage.players.Player)385 ContinuousEffect (mage.abilities.effects.ContinuousEffect)248 Effect (mage.abilities.effects.Effect)222 OneShotEffect (mage.abilities.effects.OneShotEffect)185 UUID (java.util.UUID)178 Card (mage.cards.Card)174 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)116 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)109 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)101 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)87 TargetPermanent (mage.target.TargetPermanent)84 FilterPermanent (mage.filter.FilterPermanent)71 MageObject (mage.MageObject)68 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)63 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)53 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)53 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)50 FilterCard (mage.filter.FilterCard)46