Search in sources :

Example 91 with FixedTarget

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

the class PredatorsHourLookEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (opponent == null) {
        return false;
    }
    MageObject sourceObject = source.getSourceObject(game);
    if (sourceObject == null) {
        return false;
    }
    Card topCard = opponent.getLibrary().getFromTop(game);
    if (topCard == null) {
        return false;
    }
    UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
    topCard.setFaceDown(true, game);
    // Move card to exile
    if (controller.moveCardsToExile(topCard, source, game, false, exileZoneId, sourceObject.getIdName())) {
        topCard.setFaceDown(true, game);
        Set<UUID> exileZones = (Set<UUID>) game.getState().getValue(VALUE_PREFIX + source.getSourceId().toString());
        if (exileZones == null) {
            exileZones = new HashSet<>();
            game.getState().setValue(VALUE_PREFIX + source.getSourceId().toString(), exileZones);
        }
        exileZones.add(exileZoneId);
        // You may play the card
        ContinuousEffect effect = new PredatorsHourPlayFromExileEffect();
        effect.setTargetPointer(new FixedTarget(topCard.getId(), game));
        game.addEffect(effect, source);
        // And you may spend mana as though it were mana of any color to cast it
        effect = new PredatorsHourSpendAnyManaEffect();
        effect.setTargetPointer(new FixedTarget(topCard.getId(), game));
        game.addEffect(effect, source);
        // For as long as that card remains exiled, you may look at it
        effect = new PredatorsHourLookEffect(controller.getId());
        effect.setTargetPointer(new FixedTarget(topCard.getId(), game));
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Set(java.util.Set) HashSet(java.util.HashSet) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 92 with FixedTarget

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

the class PrimordialMistCastFromExileEffect method pay.

@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
    Player controller = game.getPlayer(controllerId);
    if (controller != null) {
        if (target.choose(Outcome.Exile, controllerId, source.getSourceId(), game)) {
            Card card = game.getCard(source.getSourceId());
            if (card != null) {
                Permanent sourcePermanent = game.getPermanent(source.getSourceId());
                if (sourcePermanent != null) {
                    Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
                    Card targetCard = game.getCard(target.getFirstTarget());
                    if (targetPermanent != null && targetCard != null) {
                        String exileName = sourcePermanent.getIdName() + " <this card may be played the turn it was exiled>";
                        controller.moveCardsToExile(targetPermanent, source, game, true, source.getSourceId(), exileName);
                        targetPermanent.setFaceDown(false, game);
                        PrimordialMistCastFromExileEffect effect = new PrimordialMistCastFromExileEffect();
                        effect.setTargetPointer(new FixedTarget(targetCard.getId()));
                        game.addEffect(effect, ability);
                        this.setPaid();
                    }
                }
            }
            this.setPaid();
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) Card(mage.cards.Card)

Example 93 with FixedTarget

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

the class RakdossReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayerOrPlaneswalkerController(source.getFirstTarget());
    if (player == null) {
        return false;
    }
    Effect effect = new DiscardTargetEffect(ManacostVariableValue.REGULAR);
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 94 with FixedTarget

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

the class RakishHeirTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent permanent = game.getPermanent(event.getSourceId());
    if (damageEvent.isCombatDamage() && permanent != null && permanent.hasSubtype(SubType.VAMPIRE, game) && permanent.isControlledBy(controllerId)) {
        this.getEffects().clear();
        AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
        effect.setTargetPointer(new FixedTarget(permanent, game));
        this.addEffect(effect);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 95 with FixedTarget

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

the class RhythmOfTheWildEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
    Player player = game.getPlayer(source.getControllerId());
    if (creature == null || player == null) {
        return false;
    }
    if (player.chooseUse(outcome, "Have " + creature.getLogName() + " enter the battlefield with a +1/+1 counter on it or with haste?", null, "+1/+1 counter", "Haste", source, game)) {
        game.informPlayers(player.getLogName() + " choose to put a +1/+1 counter on " + creature.getName());
        creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
    } else {
        ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
        effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1));
        game.addEffect(effect, source);
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

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