/**
 *  Provides a top level event object for MUD events.
 *  This is a very generic kind of event and is extended by MUDEvent.
 *
 *  A common feature of all events is the source object.
 */
package mud.core;

import java.lang.*;
import java.io.*;
import mud.service.MUDEventQueue;

public class MUDEventObject extends java.lang.Object implements Serializable
{
    /**
     *  Constructs a minimal MUDEventObject.
     */
    public MUDEventObject(GameObject goSource, int iScope)
    {
    	if (goSource == null)
    	{
    	    throw new IllegalArgumentException("null source");
        }
        else
        {
            this.goSource = goSource;
            
            this.iScope = iScope;
            
            // post the event to the MUDEventQueue
            MUDEventQueue.postEvent(this);
        }
    }
    
    /**
     *  Get the source object of the MUD Event.
     */
    public GameObject getSource()
    {
        return goSource;
    }
    
    /**
     *  Override default toString().
     */
    public String toString() 
    {
        return getClass().getName() + "[source=" + goSource + "]";
    }
 
    
    // Event scoping
    public int getScope()
    {
        return iScope;
    }
    
    public void setScope(int iScope)
    {
        this.iScope = iScope;
    }
 
    /**
     *  Source GameObject.
     */
    protected transient GameObject goSource;
 
    /**
     *  Has the event been handled already?
     */
    public transient boolean bConsumed = false;
   
    
    protected int iScope;
}