Search in sources :

Example 81 with ContinuousEffect

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

the class HallOfTheBanditLordWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.MANA_PAID) {
        MageObject target = game.getObject(event.getTargetId());
        if (event.getSourceId() != null && event.getSourceId().equals(this.getSourceId()) && target != null && target.isCreature(game) && event.getFlag()) {
            if (target instanceof Spell) {
                this.creatures.add(((Spell) target).getCard().getId());
            }
        }
    }
    if (event.getType() == GameEvent.EventType.COUNTERED) {
        if (creatures.contains(event.getTargetId())) {
            creatures.remove(event.getSourceId());
        }
    }
    if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
        if (creatures.contains(event.getSourceId())) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
            // spell was e.g. exiled and goes again to stack, so previous cast has not resolved.
            if (zEvent.getToZone() == Zone.STACK) {
                creatures.remove(event.getSourceId());
            }
        }
    }
    if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
        if (creatures.contains(event.getSourceId())) {
            ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
            effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
            game.addEffect(effect, source);
            creatures.remove(event.getSourceId());
        }
    }
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Spell(mage.game.stack.Spell)

Example 82 with ContinuousEffect

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

the class HuatliWarriorPoetDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (source.getTargets().isEmpty()) {
        return true;
    }
    Target multiTarget = source.getTargets().get(0);
    for (UUID target : multiTarget.getTargets()) {
        Permanent permanent = game.getPermanent(target);
        if (permanent != null && permanent.damage(multiTarget.getTargetAmount(target), source.getSourceId(), source, game, false, true) > 0) {
            ContinuousEffect effect = new CantBlockTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(permanent, game));
            game.addEffect(effect, source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) CantBlockTargetEffect(mage.abilities.effects.common.combat.CantBlockTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 83 with ContinuousEffect

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

the class InventTarget method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (UUID targetId : targetPointer.getTargets(game, source)) {
        ContinuousEffect effect = new SwitchPowerToughnessTargetEffect(Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(targetId, game));
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SwitchPowerToughnessTargetEffect(mage.abilities.effects.common.continuous.SwitchPowerToughnessTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 84 with ContinuousEffect

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

the class InsurrectionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean result = false;
    ContinuousEffect gainControl = new GainControlTargetEffect(Duration.EndOfTurn);
    ContinuousEffect gainHaste = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
    for (Permanent creature : game.getBattlefield().getAllActivePermanents(CardType.CREATURE, game)) {
        creature.untap(game);
        gainControl.setTargetPointer(new FixedTarget(creature.getId(), game));
        gainHaste.setTargetPointer(new FixedTarget(creature.getId(), game));
        game.addEffect(gainControl, source);
        game.addEffect(gainHaste, source);
        result = true;
    }
    return result;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 85 with ContinuousEffect

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

the class KillerInstinctEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Library library = player.getLibrary();
    if (library == null || !library.hasCards()) {
        return false;
    }
    Card card = library.getFromTop(game);
    if (card == null) {
        return false;
    }
    player.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
    if (card.isCreature(game) && player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        Permanent permanent = game.getPermanent(card.getId());
        if (permanent != null) {
            FixedTarget ft = new FixedTarget(permanent, game);
            ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
            effect.setTargetPointer(ft);
            game.addEffect(effect, source);
            Effect sacrificeEffect = new SacrificeTargetEffect("Sacrifice it at the beginning of the next end step", source.getControllerId());
            sacrificeEffect.setTargetPointer(ft);
            game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) Library(mage.players.Library) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Aggregations

ContinuousEffect (mage.abilities.effects.ContinuousEffect)322 FixedTarget (mage.target.targetpointer.FixedTarget)245 Player (mage.players.Player)225 Permanent (mage.game.permanent.Permanent)202 Card (mage.cards.Card)97 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)76 UUID (java.util.UUID)65 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)55 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)50 MageObject (mage.MageObject)47 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)43 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)37 FilterCard (mage.filter.FilterCard)34 TargetPermanent (mage.target.TargetPermanent)33 Effect (mage.abilities.effects.Effect)32 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)31 OneShotEffect (mage.abilities.effects.OneShotEffect)30 Target (mage.target.Target)30 FilterPermanent (mage.filter.FilterPermanent)24 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)23