Search in sources :

Example 41 with FixedTarget

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

the class PurgatoryReturnEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId());
    if (sourcePermanent != null) {
        Player controller = game.getPlayer(sourcePermanent.getControllerId());
        if (controller != null) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
            Permanent permanent = zEvent.getTarget();
            if (permanent != null && zEvent.isDiesEvent() && !(permanent instanceof PermanentToken) && permanent.isCreature(game) && permanent.isOwnedBy(controller.getId())) {
                this.getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game));
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken)

Example 42 with FixedTarget

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

the class RemnantOfTheRisingStarEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}");
    if (player == null || !player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) {
        return false;
    }
    int xValue = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    cost.add(new GenericManaCost(xValue));
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return false;
    }
    Permanent permanent = (Permanent) getValue("permanentEnteringBattlefield");
    if (permanent == null) {
        return false;
    }
    game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance(xValue)).setTargetPointer(new FixedTarget(permanent, game)), false), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) Hint(mage.abilities.hint.Hint) ValueHint(mage.abilities.hint.ValueHint)

Example 43 with FixedTarget

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

the class SabaccGameEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
        if (targetPermanent != null) {
            Player opponent = game.getPlayer(targetPermanent.getControllerId());
            if (opponent != null) {
                FilterPermanent filter = new FilterPermanent("permanent controlled by " + controller.getName());
                filter.add(new ControllerIdPredicate(controller.getId()));
                TargetPermanent target = new TargetPermanent(1, 1, filter, true);
                Permanent chosenPermanent = null;
                if (target.chooseTarget(outcome, opponent.getId(), source, game)) {
                    chosenPermanent = game.getPermanent(target.getFirstTarget());
                }
                boolean flipWin = controller.flipCoin(source, game, true);
                if (flipWin) {
                    ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, controller.getId());
                    effect.setTargetPointer(new FixedTarget(targetPermanent, game));
                    game.addEffect(effect, source);
                } else if (chosenPermanent != null) {
                    ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, opponent.getId());
                    effect.setTargetPointer(new FixedTarget(chosenPermanent, game));
                    game.addEffect(effect, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 44 with FixedTarget

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

the class SaffiEriksdotterDelayedTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    DelayedTriggeredAbility delayedAbility = new SaffiEriksdotterDelayedTriggeredAbility(new FixedTarget(this.getTargetPointer().getFirst(game, source)));
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility)

Example 45 with FixedTarget

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

the class SkyfireKirinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent targetCreature = null;
    for (Target target : source.getTargets()) {
        if (target instanceof TargetPermanent) {
            targetCreature = game.getPermanent(target.getFirstTarget());
        }
    }
    if (targetCreature != null) {
        ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

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