/**
* 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 );
}
}