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 ##########   #####"
**
**  $Id$
**
**  Class History
**
**  Date        Name         Description
**  ---------|------------|-----------------------------------------------
**  24Aug98     subtle       start of recorded history
**
*/

package key.commands;

import key.*;
import key.primitive.*;
import java.io.IOException;

import java.util.StringTokenizer;

public class Register extends Command
{
	public Register()
	{
		setKey( "register" );
		usage = "";
	}
	
	public void run( Player p, StringTokenizer args, String fullLine, CategoryCommand caller, InteractiveConnection ic, Flags flags ) throws IOException
	{
		if( p.willSync() )
		{
			ic.sendFeedback( "This character is already registered." );
		}
		else
		{
			if( !p.getCanSave() )
			{
				ic.sendFeedback( "You will first need to ask a superuser to grant you 'residency'.  When they do so, you will be instructed to run this command again in order to enter the rest of your details." );
			}
			else
			{
				if( !p.hasPassword() )
				{
					p.command( "password", ic, false );
				}
				
				EmailAddress ea = p.getEmail();
				
				if( !ea.isSet() )
				{
					p.command( "email", ic, false );
				}
				else if( !ea.isValid() )
				{
					ic.sendFeedback( "You have already set an email address, but have not yet verified that you recieved the email we sent you.  If you wish to change it, use the 'email' command." );
				}
				else
					ic.sendFeedback( "You have already set an email address and verified it." );
			}
		}
	}
}