Search in sources :

Example 76 with Spell

use of mage.game.stack.Spell 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 77 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class InkTreaderNephilimEffect method checkInterveningIfClause.

@Override
public boolean checkInterveningIfClause(Game game) {
    Spell spell = (Spell) getEffects().get(0).getValue("triggeringSpell");
    if (spell == null) {
        return false;
    }
    boolean flag = false;
    for (TargetAddress addr : TargetAddress.walk(spell)) {
        Target targetInstance = addr.getTarget(spell);
        for (UUID target : targetInstance.getTargets()) {
            if (target == null) {
                continue;
            }
            Permanent permanent = game.getPermanent(target);
            if (permanent == null || !permanent.getId().equals(getSourceId())) {
                return false;
            }
            if (getSourceObjectZoneChangeCounter() != 0 && getSourceObjectZoneChangeCounter() != permanent.getZoneChangeCounter(game)) {
                return false;
            }
            flag = true;
        }
    }
    return flag;
}
Also used : Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) TargetAddress(mage.util.TargetAddress) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Example 78 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class InsistWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.SPELL_CAST && ready) {
        if (uncounterableSpell == null && event.getPlayerId().equals(this.getControllerId())) {
            Spell spell = game.getStack().getSpell(event.getTargetId());
            if (spell != null && (spell.isCreature(game))) {
                uncounterableSpell = spell.getId();
                ready = false;
            }
        }
    }
}
Also used : Spell(mage.game.stack.Spell)

Example 79 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class KindredDenialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Spell spell = game.getSpell(source.getFirstTarget());
    if (player == null || spell == null) {
        return false;
    }
    int manaValue = spell.getManaValue();
    spell.counter(source, game);
    FilterCard filter = new FilterCard();
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, manaValue));
    player.seekCard(filter, source, game);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Example 80 with Spell

use of mage.game.stack.Spell in project mage by magefree.

the class LivingBreakthroughEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    Spell spell = (Spell) getValue("spellCast");
    if (spell != null) {
        this.manaValue = spell.getManaValue();
    }
}
Also used : Spell(mage.game.stack.Spell)

Aggregations

Spell (mage.game.stack.Spell)311 Player (mage.players.Player)155 Permanent (mage.game.permanent.Permanent)90 UUID (java.util.UUID)79 MageObject (mage.MageObject)69 Card (mage.cards.Card)51 TargetSpell (mage.target.TargetSpell)48 StackObject (mage.game.stack.StackObject)42 FilterCard (mage.filter.FilterCard)38 FilterSpell (mage.filter.FilterSpell)36 FixedTarget (mage.target.targetpointer.FixedTarget)33 MageObjectReference (mage.MageObjectReference)24 Effect (mage.abilities.effects.Effect)22 OneShotEffect (mage.abilities.effects.OneShotEffect)22 Target (mage.target.Target)22 Ability (mage.abilities.Ability)20 SpellAbility (mage.abilities.SpellAbility)16 FilterPermanent (mage.filter.FilterPermanent)15 TargetCard (mage.target.TargetCard)15 TargetPlayer (mage.target.TargetPlayer)14