Search in sources :

Example 1 with CastFromHandWatcher

use of mage.watchers.common.CastFromHandWatcher in project mage by magefree.

the class HarnessTheStormEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (super.checkTrigger(event, game)) {
        CastFromHandWatcher watcher = game.getState().getWatcher(CastFromHandWatcher.class);
        if (watcher != null && watcher.spellWasCastFromHand(event.getSourceId())) {
            Spell spell = game.getState().getStack().getSpell(event.getSourceId());
            if (spell != null) {
                FilterCard filterCard = new FilterCard("a card named " + spell.getName() + " in your graveyard");
                filterCard.add(new NamePredicate(spell.getName()));
                this.getTargets().clear();
                this.getTargets().add(new TargetCardInYourGraveyard(filterCard));
                return true;
            }
        }
    }
    return false;
}
Also used : CastFromHandWatcher(mage.watchers.common.CastFromHandWatcher) FilterCard(mage.filter.FilterCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterInstantOrSorcerySpell(mage.filter.common.FilterInstantOrSorcerySpell) FilterSpell(mage.filter.FilterSpell) Spell(mage.game.stack.Spell)

Example 2 with CastFromHandWatcher

use of mage.watchers.common.CastFromHandWatcher in project mage by magefree.

the class BanishIntoFableEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!super.checkTrigger(event, game)) {
        return false;
    }
    CastFromHandWatcher watcher = game.getState().getWatcher(CastFromHandWatcher.class);
    if (watcher == null || !watcher.spellWasCastFromHand(event.getSourceId())) {
        return false;
    }
    Spell spell = game.getState().getStack().getSpell(event.getSourceId());
    if (spell == null) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new BanishIntoFableEffect(spell.getId()));
    return true;
}
Also used : CastFromHandWatcher(mage.watchers.common.CastFromHandWatcher) Spell(mage.game.stack.Spell)

Aggregations

Spell (mage.game.stack.Spell)2 CastFromHandWatcher (mage.watchers.common.CastFromHandWatcher)2 FilterCard (mage.filter.FilterCard)1 FilterSpell (mage.filter.FilterSpell)1 FilterInstantOrSorcerySpell (mage.filter.common.FilterInstantOrSorcerySpell)1 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)1 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)1