Search in sources :

Example 36 with Effect

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

the class InvokePrejudiceEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) {
        Spell spell = (Spell) game.getObject(event.getTargetId());
        if (spell != null && spell.isCreature(game)) {
            boolean creatureSharesAColor = false;
            ObjectColor spellColor = spell.getColor(game);
            for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterControlledCreaturePermanent(), getControllerId(), game)) {
                if (spellColor.shares(permanent.getColor(game))) {
                    creatureSharesAColor = true;
                    break;
                }
            }
            if (!creatureSharesAColor) {
                for (Effect effect : getEffects()) {
                    effect.setTargetPointer(new FixedTarget(event.getTargetId()));
                }
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ObjectColor(mage.ObjectColor) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Effect(mage.abilities.effects.Effect) CounterUnlessPaysEffect(mage.abilities.effects.common.CounterUnlessPaysEffect) Spell(mage.game.stack.Spell)

Example 37 with Effect

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

the class LabyrinthRaptorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(permanent.getId(), game));
    if (player == null) {
        return false;
    }
    FilterPermanent filterPermanent = new FilterPermanent("creature blocking " + permanent.getIdName());
    filterPermanent.add(new BlockingAttackerIdPredicate(permanent.getId()));
    Effect effect = new SacrificeEffect(filterPermanent, 1, "");
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) BlockingAttackerIdPredicate(mage.filter.predicate.permanent.BlockingAttackerIdPredicate) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Example 38 with Effect

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

the class MacabreMockeryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (card == null) {
        return false;
    }
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        return false;
    }
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        return false;
    }
    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
    effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(effect, source);
    effect = new BoostTargetEffect(2, 0, Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(permanent, game));
    game.addEffect(effect, source);
    Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + permanent.getLogName(), controller.getId());
    sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
    game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) Card(mage.cards.Card)

Example 39 with Effect

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

the class OathOfLiegesPredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player activePlayer = game.getPlayer(game.getActivePlayerId());
    if (activePlayer != null) {
        if (activePlayer.chooseUse(outcome, "Search your library for a basic land card, put that card onto the battlefield, then shuffle?", source, game)) {
            Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, false, Outcome.PutLandInPlay, true);
            effect.setTargetPointer(new FixedTarget(game.getActivePlayerId()));
            return effect.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPlayer(mage.filter.FilterPlayer) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer) SearchLibraryPutInPlayTargetPlayerEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayTargetPlayerEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SearchLibraryPutInPlayTargetPlayerEffect(mage.abilities.effects.common.search.SearchLibraryPutInPlayTargetPlayerEffect) Effect(mage.abilities.effects.Effect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary)

Example 40 with Effect

use of mage.abilities.effects.Effect 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)

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