Search in sources :

Example 61 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class GoblinTutorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int amount = controller.rollDice(outcome, source, game, 6);
        Effect effect = null;
        // 6 - An instant or sorcery card
        if (amount == 2) {
            effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, filter), true);
        } else if (amount == 3) {
            effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_ENTCHANTMENT), true);
        } else if (amount == 4) {
            effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_ARTIFACT), true);
        } else if (amount == 5) {
            effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_CREATURE), true);
        } else if (amount == 6) {
            effect = new SearchLibraryPutInHandEffect(new TargetCardInLibrary(0, 1, new FilterInstantOrSorceryCard()), true);
        }
        if (effect != null) {
            effect.apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary)

Example 62 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class HamletbackGoliathEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    UUID targetId = event.getTargetId();
    Permanent permanent = game.getPermanent(targetId);
    if (permanent != null && permanent.isCreature(game) && !(targetId.equals(this.getSourceId()))) {
        for (Effect effect : this.getEffects()) {
            effect.setTargetPointer(new FixedTarget(permanent, game));
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Example 63 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class LiesaForgottenArchangelReplacementEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Effect effect = new ReturnToHandTargetEffect();
    effect.setText("return that card to its owner's hand");
    effect.setTargetPointer(targetPointer);
    DelayedTriggeredAbility ability = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(ability, source);
    return true;
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect)

Example 64 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class LichsMasteryLoseLifeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    FilterPermanent filter = new FilterPermanent();
    filter.add(new ControllerIdPredicate(controller.getId()));
    for (int i = 0; i < amount; i++) {
        int handCount = controller.getHand().size();
        int graveCount = controller.getGraveyard().size();
        int permCount = game.getBattlefield().getActivePermanents(filter, controller.getId(), game).size();
        if (graveCount + handCount == 0 || (permCount > 0 && controller.chooseUse(Outcome.Exile, "Exile permanent you control? (No = from hand or graveyard)", source, game))) {
            Target target = new TargetControlledPermanent(1, 1, new FilterControlledPermanent(), true);
            controller.choose(outcome, target, source.getSourceId(), game);
            Effect effect = new ExileTargetEffect();
            effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
            effect.apply(game, source);
        } else if (graveCount == 0 || (handCount > 0 && controller.chooseUse(Outcome.Exile, "Exile a card from your hand? (No = from graveyard)", source, game))) {
            Target target = new TargetCardInHand(1, 1, new FilterCard());
            controller.choose(outcome, target, source.getSourceId(), game);
            Card card = controller.getHand().get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.EXILED, source, game);
            }
        } else if (graveCount > 0) {
            Target target = new TargetCardInYourGraveyard(1, 1, new FilterCard(), true);
            target.choose(Outcome.Exile, source.getControllerId(), source.getSourceId(), game);
            Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.EXILED, source, game);
            }
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) TargetCardInHand(mage.target.common.TargetCardInHand) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) LoseGameSourceControllerEffect(mage.abilities.effects.common.LoseGameSourceControllerEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 65 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class LifelineEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card != null) {
        Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
        effect.setTargetPointer(new FixedTarget(card, game));
        effect.setText("return that card to the battlefield under it's owner's control at the beginning of the next end step");
        game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) ReturnToBattlefieldUnderOwnerControlTargetEffect(mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) Card(mage.cards.Card)

Aggregations

Effect (mage.abilities.effects.Effect)328 OneShotEffect (mage.abilities.effects.OneShotEffect)254 FixedTarget (mage.target.targetpointer.FixedTarget)224 Permanent (mage.game.permanent.Permanent)180 Player (mage.players.Player)167 UUID (java.util.UUID)75 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)60 Card (mage.cards.Card)57 MageObject (mage.MageObject)41 ContinuousEffect (mage.abilities.effects.ContinuousEffect)40 TargetPermanent (mage.target.TargetPermanent)39 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)38 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)38 FilterPermanent (mage.filter.FilterPermanent)29 ReturnToBattlefieldUnderOwnerControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)28 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)27 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)25 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)24 AttachEffect (mage.abilities.effects.common.AttachEffect)23 Target (mage.target.Target)22