Search in sources :

Example 61 with FixedTarget

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

the class AllianceOfArmsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int xSum = 0;
        xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", controller, source, game);
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            if (!Objects.equals(playerId, controller.getId())) {
                Player player = game.getPlayer(playerId);
                if (player != null) {
                    xSum += ManaUtil.playerPaysXGenericMana(false, "Alliance of Arms", player, source, game);
                }
            }
        }
        if (xSum > 0) {
            for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
                Effect effect = new CreateTokenTargetEffect(new SoldierToken(), xSum);
                effect.setTargetPointer(new FixedTarget(playerId));
                effect.apply(game, source);
            }
        }
        // prevent undo
        controller.resetStoredBookmark(game);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SoldierToken(mage.game.permanent.token.SoldierToken) Player(mage.players.Player) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Example 62 with FixedTarget

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

the class BalduvianDeadEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    CreateTokenEffect effect = new CreateTokenEffect(new BalduvianToken());
    effect.apply(game, source);
    for (UUID tokenId : effect.getLastAddedTokenIds()) {
        Permanent tokenPermanent = game.getPermanent(tokenId);
        if (tokenPermanent != null) {
            SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("Sacrifice the token at the beginning of the next end step", source.getControllerId());
            sacrificeEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
            DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
            game.addDelayedTriggeredAbility(delayedAbility, source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) BalduvianToken(mage.game.permanent.token.BalduvianToken) UUID(java.util.UUID)

Example 63 with FixedTarget

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

the class BreenaTheDemagogueEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!game.getOpponents(getControllerId()).contains(event.getTargetId())) {
        return false;
    }
    getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
    getEffects().setValue("attackedPlayer", event.getTargetId());
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget)

Example 64 with FixedTarget

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

the class BreyasApprenticeEffect 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) {
        return false;
    }
    Card card = controller.getLibrary().getFromTop(game);
    if (card == null) {
        return false;
    }
    controller.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
    game.addEffect(new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.UntilEndOfYourNextTurn).setTargetPointer(new FixedTarget(card, game)), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) MageObject(mage.MageObject) Card(mage.cards.Card)

Example 65 with FixedTarget

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

the class CemeteryPucaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent copyToCreature = game.getPermanent(source.getSourceId());
    if (copyToCreature != null) {
        Permanent copyFromCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
        if (copyFromCreature != null) {
            game.copyPermanent(Duration.WhileOnBattlefield, copyFromCreature, copyToCreature.getId(), source, new EmptyCopyApplier());
            ContinuousEffect effect = new GainAbilityTargetEffect(new DiesCreatureTriggeredAbility(new DoIfCostPaid(new CemeteryPucaEffect(), new ManaCostsImpl("{1}")), false, StaticFilters.FILTER_PERMANENT_A_CREATURE, true), Duration.WhileOnBattlefield);
            effect.setTargetPointer(new FixedTarget(copyToCreature.getId(), game));
            game.addEffect(effect, source);
            return true;
        }
    }
    return false;
}
Also used : DiesCreatureTriggeredAbility(mage.abilities.common.DiesCreatureTriggeredAbility) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

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