key0-96/
key0-96/doc/key/
key0-96/doc/key/credits/
key0-96/doc/key/developers/
key0-96/doc/key/developers/resources/
key0-96/setup/caves/
key0-96/setup/help/
key0-96/setup/ruins/
key0-96/src/
key0-96/src/commands/
key0-96/src/events/
key0-96/src/hack/
key0-96/src/sql/
key0-96/src/swing/
key0-96/src/talker/forest/
key0-96/src/talker/objects/
key0-96/src/terminals/
/**
  *  Broadcast
  *
  *
 */

package key.effect;

import key.*;
import java.util.StringTokenizer;

/**
  *  A communication effect that goes to an entire
  *  medium, such as a room or channel.  (Technically,
  *  it goes to any scape)
 */
public class Broadcast extends Communication
{
	protected Scape loc;
	
	protected String mainMessage;
	protected String selfMessage;
	
	/**
	  *  If it echos to the scape, it must always re-echo
	  *  to the originator - this boolean is set if the
	  *  originator is splashed, so if its still false
	  *  after all, then re-splash them.
	 */
	protected boolean gotOriginator;
	
	/**
	  *  Creates a new communication
	  *
	  * @param from the player who sent it
	  * @param location where the local effect is to take place
	  * @param main the message to show to everyone in the location scape
	  * @param self the message to show to the player
	 */
	public Broadcast( Scape location, Player from, String main, String self )
	{
		super( from );
		mainMessage = main;
		selfMessage = self;
		loc = location;
	}

	public String getMessage( Player receiver )
	{
		if( receiver == originator )
		{
			gotOriginator = true;
			return( selfMessage );
		}
		else
			return( mainMessage );
	}

	public void cause()
	{
		gotOriginator = false;
		loc.splash( this, null );
		
		if( !gotOriginator )
			originator.splash( this, null );
		
		//Log.log( loc.getName(), mainMessage );
	}
}