Search in sources :

Example 71 with FixedTarget

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

the class DanceOfTheManseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Cards cards = new CardsImpl(source.getTargets().stream().map(Target::getTargets).flatMap(Collection::stream).map(game::getCard).filter(Objects::nonNull).collect(Collectors.toSet()));
    player.moveCards(cards, Zone.BATTLEFIELD, source, game);
    if (source.getManaCostsToPay().getX() < 6) {
        return true;
    }
    cards.stream().map(game::getPermanent).filter(Objects::nonNull).forEach(permanent -> {
        ContinuousEffect effect = new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.CREATURE);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
        effect = new SetPowerToughnessTargetEffect(4, 4, Duration.EndOfGame);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    });
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Objects(java.util.Objects) Collection(java.util.Collection) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SetPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect) AddCardTypeTargetEffect(mage.abilities.effects.common.continuous.AddCardTypeTargetEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 72 with FixedTarget

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

the class DonateEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
    if (targetPlayer != null && permanent != null) {
        ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, targetPlayer.getId());
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 73 with FixedTarget

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

the class FatalLoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player chosenOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (controller != null && chosenOpponent != null) {
        if (chosenOpponent.chooseUse(Outcome.Neutral, "If you choose Yes, the controller draws three cards. If no, the controller gets to destroy up to two target creatures that you control and you get to draw up to 3 cards. Those creatures can't be regenerated.", source, game)) {
            controller.drawCards(3, source, game);
        } else {
            FilterCreaturePermanent filter = new FilterCreaturePermanent("chosen opponent's creature");
            filter.add(new ControllerIdPredicate(chosenOpponent.getId()));
            TargetCreaturePermanent target = new TargetCreaturePermanent(0, 2, filter, false);
            if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game)) {
                for (UUID targetId : target.getTargets()) {
                    Effect destroyCreature = new DestroyTargetEffect(true);
                    destroyCreature.setTargetPointer(new FixedTarget(targetId, game));
                    destroyCreature.apply(game, source);
                }
                Effect opponentDrawsCards = new DrawCardTargetEffect(StaticValue.get(3), false, true);
                opponentDrawsCards.setTargetPointer(new FixedTarget(chosenOpponent.getId()));
                opponentDrawsCards.apply(game, source);
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Example 74 with FixedTarget

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

the class FootstepsOfTheGoryoEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Card card = game.getCard(getTargetPointer().getFirst(game, source));
        if (card != null) {
            if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                Permanent permanent = game.getPermanent(card.getId());
                if (permanent != null) {
                    // Sacrifice it at end of turn
                    Effect sacrificeEffect = new SacrificeTargetEffect("Sacrifice that creature at the beginning of next end step", source.getControllerId());
                    sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
                    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
                    game.addDelayedTriggeredAbility(delayedAbility, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) Card(mage.cards.Card)

Example 75 with FixedTarget

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

the class FormOfTheSquirrelCantCastEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player sourceController = game.getPlayer(source.getControllerId());
    if (sourceController != null) {
        CreateTokenEffect effect = new CreateTokenEffect(new SquirrelToken());
        effect.apply(game, source);
        game.getState().setValue(source.getSourceId() + "_token", effect.getLastAddedTokenIds());
        for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
            Effect loseGameEffect = new LoseGameTargetPlayerEffect();
            loseGameEffect.setTargetPointer(new FixedTarget(sourceController.getId(), game));
            LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(loseGameEffect, false);
            ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
            continuousEffect.setTargetPointer(new FixedTarget(addedTokenId, game));
            game.addEffect(continuousEffect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) LeavesBattlefieldTriggeredAbility(mage.abilities.common.LeavesBattlefieldTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) LoseGameTargetPlayerEffect(mage.abilities.effects.common.LoseGameTargetPlayerEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) GainAbilityControllerEffect(mage.abilities.effects.common.continuous.GainAbilityControllerEffect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) LoseGameTargetPlayerEffect(mage.abilities.effects.common.LoseGameTargetPlayerEffect) CantAttackYouAllEffect(mage.abilities.effects.common.combat.CantAttackYouAllEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) SquirrelToken(mage.game.permanent.token.SquirrelToken)

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