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/
/**
  * Page 
  *
  *
 */

package key.effect;

import key.*;

import java.util.Enumeration;

/**
  *  A communication effect that goes to an individual
  *  player with no message (preset message). 
 */
public class Page extends Communication
{
	Player directedAt;
	String feedbackMessage;
	String otherMessage;
	
	/**
	  *  Creates a new communication
	  *
	  * @param from the player who sent it
	  * @param to the player to page
	  * @param self the string tp tell the sender
	 */
	public Page( Player from, Player to, String feedback, String other )
	{
		super( from );
		
		directedAt = to;
		otherMessage = other;
		feedbackMessage = feedback;
	}

	public String getMessage( Player receiver )
	{
		if( receiver == directedAt )
			return( otherMessage );
		else
			throw new UnexpectedResult( "someone received a Page effect who is not the receiver" );
	}

	public void cause()
	{
		SuppressionList sl = new SuppressionList();
		
		directedAt.splash( this, sl );
		
		if( sl.count() > 0 )
		{
			for( Enumeration e = sl.elements(); e.hasMoreElements(); )
			{
				SuppressionList.Entry sle = (SuppressionList.Entry) e.nextElement();
				originator.sendFailure( sle.getText() );
			}
		}
		else
			originator.sendFeedback( feedbackMessage );
	}
	
	public void sending( String message, Player p )
	{
		p.beep();
	}
}