Package mage.watchers.common

Source Code of mage.watchers.common.CastFromHandWatcher

package mage.watchers.common;

import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.watchers.Watcher;

public class CastFromHandWatcher extends Watcher {
    public CastFromHandWatcher() {
        super("CastFromHand", WatcherScope.CARD);
    }

    public CastFromHandWatcher(final CastFromHandWatcher watcher) {
        super(watcher);
    }

    @Override
    public void watch(GameEvent event, Game game) {
         if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) {
            Spell spell = (Spell) game.getObject(event.getTargetId());
            if (this.getSourceId().equals(spell.getSourceId())) {
               condition = true;
            }
        }
    }

    @Override
    public CastFromHandWatcher copy() {
        return new CastFromHandWatcher(this);
    }
}
TOP

Related Classes of mage.watchers.common.CastFromHandWatcher

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.