Search in sources :

Example 21 with FixedTarget

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

the class HatefulEidolonTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    int auraCount = 0;
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (!zEvent.isDiesEvent()) {
        return false;
    }
    Permanent deadCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (deadCreature.getAttachments().isEmpty()) {
        return false;
    }
    for (UUID auraId : deadCreature.getAttachments()) {
        Permanent attachment = game.getPermanentOrLKIBattlefield(auraId);
        if (attachment.getControllerId().equals(controllerId) && attachment.isEnchantment(game)) {
            // Shadowspear or any other equipment does not count
            auraCount += 1;
        }
    }
    if (auraCount == 0) {
        // just equipment not aura's
        return false;
    }
    Player controller = game.getPlayer(controllerId);
    if (controller != null && controller.canRespond()) {
        this.getEffects().clear();
        DrawCardTargetEffect drawCard = new DrawCardTargetEffect(auraCount);
        drawCard.setTargetPointer(new FixedTarget(controllerId));
        this.addEffect(drawCard);
        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) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) UUID(java.util.UUID)

Example 22 with FixedTarget

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

the class HaukensInsightWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
            MageObject sourceObject = source.getSourceObject(game);
            String exileName = sourceObject == null ? null : sourceObject.getIdName();
            controller.moveCardsToExile(card, source, game, true, exileId, exileName);
            if (game.getState().getZone(card.getId()) == Zone.EXILED) {
                card.setFaceDown(true, game);
                HaukensInsightLookEffect effect = new HaukensInsightLookEffect(controller.getId());
                effect.setTargetPointer(new FixedTarget(card, game));
                game.addEffect(effect, source);
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) MageObject(mage.MageObject) UUID(java.util.UUID) Card(mage.cards.Card)

Example 23 with FixedTarget

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

the class HauntingWindTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
        Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
        if (permanent == null || !permanent.isArtifact(game)) {
            return false;
        }
        StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
        if (stackAbility == null) {
            return false;
        }
        String abilityText = stackAbility.getRule(true);
        if (abilityText.contains("{T}:") || abilityText.contains("{T},") || abilityText.contains("{T} or")) {
            return false;
        }
        for (Effect effect : this.getEffects()) {
            effect.setTargetPointer(new FixedTarget(permanent.getControllerId(), game));
        }
        return true;
    }
    if (event.getType() == GameEvent.EventType.TAPPED) {
        Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
        if (permanent == null || !permanent.isArtifact(game)) {
            return false;
        }
        for (Effect effect : this.getEffects()) {
            effect.setTargetPointer(new FixedTarget(permanent.getControllerId(), game));
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) StackAbility(mage.game.stack.StackAbility)

Example 24 with FixedTarget

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

the class HateMirageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    source.getTargets().stream().map(Target::getTargets).flatMap(Collection::stream).forEach(uuid -> {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true);
        effect.setTargetPointer(new FixedTarget(uuid, game));
        effect.apply(game, source);
        effect.exileTokensCreatedAtNextEndStep(game, source);
    });
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 25 with FixedTarget

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

the class InameAsOneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
    if (controller != null && sourceObject != null && targetCard != null) {
        if (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return Spirit card?", source, game)) {
            // In a Commander game, you may send Iname to the Command Zone instead of exiling it during the resolution
            // of its ability. If you do, its ability still works. Iname's ability only requires that you attempted to
            // exile it, not that it actually gets to the exile zone. This is similar to how destroying a creature
            // (with, for example, Rest in Peace) doesn't necessarily ensure that creature will end up in the graveyard;
            // it just so happens that the action of exiling something and the exile zone both use the same word: "exile".
            Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
            effect.setTargetPointer(new FixedTarget(targetCard.getId(), targetCard.getZoneChangeCounter(game)));
            new ExileSourceEffect().apply(game, source);
            return effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) Player(mage.players.Player) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) MageObject(mage.MageObject) ExileSourceEffect(mage.abilities.effects.common.ExileSourceEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SearchLibraryPutInPlayEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect) Effect(mage.abilities.effects.Effect) ReturnFromGraveyardToBattlefieldTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect) Card(mage.cards.Card) FilterPermanentCard(mage.filter.common.FilterPermanentCard)

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