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/
/*
**               j###t  ########## ####   ####
**              j###t   ########## ####   ####
**             j###T               "###L J###"
**          ######P'    ##########  #########
**          ######k,    ##########   T######T
**          ####~###L   ####
**          #### q###L  ##########   .#####
**          ####  \###L ##########   #####"
**
**  Class: Through
**
**  Class History
**
**  Date        Name         Through
**  ---------|------------|-----------------------------------------------
**  28Jul97     exile        command created
*/

package key.commands;

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

public class Through extends Command
{
    public static final int MAX_LINES = 6;
	public static final int MAX_BYTES = MAX_LINES * 80;
	
	public Through()
	{
		setKey( "through" );
		usage = "<exit>";
	}
	
	 public void run( Player p, StringTokenizer args, String fullLine, CategoryCommand caller, InteractiveConnection ic, Flags flags ) throws IOException
     {
		if( args.hasMoreTokens() )
		{
			String exitName = (String)args.nextToken();

			Paragraph through = null;
			
				// try to get the exit
			try
			{
				Exit e = (Exit) p.getLocation().getExactElement( exitName );

					// the exit doesn't exit
				if( e == null )
				{
					ic.sendFeedback( exitName + " is not an exit here!" );
					return;
				}
				
				through = (Paragraph) e.getProperty( "through" );
				
				if( through == null ) // new through
					through = new TextParagraph();
				
				Paragraph para = Editor.edit( p, through, ic, MAX_LINES, MAX_BYTES );
				
				if( para == through )
				{
					ic.sendFeedback( "You make no changes to the through description." );
				}
				else
				{
					e.setProperty( "through", para );
					ic.sendFeedback( "You change what people will see when they go through " + exitName + ".");
				}
			}
			catch( AccessViolationException e )
			{
				ic.sendFeedback( "You do not have permission to edit " + exitName );
				return;
			}

		}
		else
			usage( ic );
	}
}