Search in sources :

Example 81 with Effect

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

the class CurseOfDisturbanceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment != null) {
        Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
        if (enchantedPlayer != null) {
            Set<UUID> players = new HashSet<>();
            for (UUID attacker : game.getCombat().getAttackers()) {
                UUID defender = game.getCombat().getDefenderId(attacker);
                if (defender.equals(enchantedPlayer.getId()) && game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
                    players.add(game.getPermanent(attacker).getControllerId());
                }
            }
            players.add(source.getControllerId());
            for (UUID player : players) {
                game.getPlayer(player);
                Effect effect = new CreateTokenTargetEffect(new ZombieToken());
                effect.setTargetPointer(new FixedTarget(player));
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) ZombieToken(mage.game.permanent.token.ZombieToken) Permanent(mage.game.permanent.Permanent) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 82 with Effect

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

the class CurseOfFoolsWisdomTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
    if (enchantment == null || !event.getPlayerId().equals(enchantment.getAttachedTo())) {
        return false;
    }
    this.getEffects().clear();
    Effect effect = new LoseLifeTargetEffect(2);
    effect.setTargetPointer(new FixedTarget(event.getPlayerId(), game));
    this.addEffect(effect);
    this.addEffect(new GainLifeEffect(2));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) LoseLifeTargetEffect(mage.abilities.effects.common.LoseLifeTargetEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) LoseLifeTargetEffect(mage.abilities.effects.common.LoseLifeTargetEffect) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 83 with Effect

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

the class UntapAllNonlandsTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment != null) {
        Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
        if (enchantedPlayer != null) {
            Set<UUID> players = new HashSet<>();
            for (UUID attacker : game.getCombat().getAttackers()) {
                UUID defender = game.getCombat().getDefenderId(attacker);
                if (defender.equals(enchantedPlayer.getId()) && game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
                    players.add(game.getPermanent(attacker).getControllerId());
                }
            }
            players.add(source.getControllerId());
            for (UUID player : players) {
                game.getPlayer(player);
                Effect effect = new UntapAllNonlandsTargetEffect();
                effect.setTargetPointer(new FixedTarget(player));
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 84 with Effect

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

the class CurseOfVerbosityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment != null) {
        Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
        if (enchantedPlayer != null) {
            Set<UUID> players = new HashSet<>();
            for (UUID attacker : game.getCombat().getAttackers()) {
                UUID defender = game.getCombat().getDefenderId(attacker);
                if (defender.equals(enchantedPlayer.getId()) && game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
                    players.add(game.getPermanent(attacker).getControllerId());
                }
            }
            players.add(source.getControllerId());
            for (UUID player : players) {
                game.getPlayer(player);
                Effect effect = new DrawCardTargetEffect(1);
                effect.setTargetPointer(new FixedTarget(player));
                effect.apply(game, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 85 with Effect

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

the class CyclopeanTombCounterWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObjectReference mor = new MageObjectReference(source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game);
    CyclopeanTombCounterWatcher watcher = game.getState().getWatcher(CyclopeanTombCounterWatcher.class);
    if (controller != null && watcher != null) {
        Set<MageObjectReference> landRef = watcher.landMiredByCyclopeanTombInstance(mor, game);
        if (landRef == null || landRef.isEmpty()) {
            // no lands got mire counter from that instance
            return true;
        }
        FilterLandPermanent filter = new FilterLandPermanent("a land with a mire counter added from the Cyclopean Tomb instance (" + landRef.size() + " left)");
        Set<PermanentIdPredicate> idPref = new HashSet<>();
        for (MageObjectReference ref : landRef) {
            Permanent land = ref.getPermanent(game);
            if (land != null) {
                idPref.add(new PermanentIdPredicate(land.getId()));
            }
        }
        filter.add(Predicates.or(idPref));
        TargetLandPermanent target = new TargetLandPermanent(1, 1, filter, true);
        /*Player must choose a land each upkeep. Using the message are above the player hand where frequent interactions
             * take place is the most logical way to prompt for this scenario. A new constructor added to provide a not optional
             * option for any cards like this where the player must choose a target in such the way this card requires.
             */
        if (controller.chooseTarget(Outcome.Neutral, target, source, game)) {
            Permanent chosenLand = game.getPermanent(target.getFirstTarget());
            if (chosenLand != null) {
                Effect effect = new RemoveAllCountersTargetEffect(CounterType.MIRE);
                effect.setTargetPointer(new FixedTarget(chosenLand, game));
                effect.apply(game, source);
                landRef.remove(new MageObjectReference(chosenLand, game));
            }
        }
        return true;
    }
    return false;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) RemoveAllCountersTargetEffect(mage.abilities.effects.common.counter.RemoveAllCountersTargetEffect) BecomesBasicLandTargetEffect(mage.abilities.effects.common.continuous.BecomesBasicLandTargetEffect) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) TargetLandPermanent(mage.target.common.TargetLandPermanent) RemoveAllCountersTargetEffect(mage.abilities.effects.common.counter.RemoveAllCountersTargetEffect) MageObjectReference(mage.MageObjectReference)

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