com.planet_ink.coffee_mud.Libraries.interfaces
Interface CharCreationLibrary

All Superinterfaces:
java.lang.Cloneable, CMLibrary, CMObject, java.lang.Comparable<CMObject>
All Known Implementing Classes:
CharCreation

public interface CharCreationLibrary
extends CMLibrary

This library manages everything related to logging a player or account in, creating a character, the account menu, certain login procedures, the rules around player names, start rooms, death rooms, and morgue rooms.


Nested Class Summary
static class CharCreationLibrary.LoginResult
          A response object from one of the login system methods, basically telling the caller something about the results of what was attempted.
static interface CharCreationLibrary.LoginSession
          This is the main login state machine transaction object.
static class CharCreationLibrary.NewCharNameCheckResult
          A response object from one of the name checking methods, telling the caller some specifics about the attempt to create a new character by testing a new name.
 
Method Summary
 boolean canChangeToThisClass(MOB mob, CharClass thisClass, int theme)
          Returns whether the given mob can change to the given class (that is, to become level 0 in that class) in the given theme.
 java.util.List<CharClass> classQualifies(MOB mob, int theme)
          Returns the list of all character classes that the given mob can change into, given their currrent state, and the given theme.
 CharCreationLibrary.LoginResult completePlayerLogin(Session session, boolean wizi)
          Takes the given session and mobs login by putting the mob into the given start room in the world, checking their email, and seeing if they are allowed in.
 CharCreationLibrary.LoginResult createCharacter(java.lang.String login, Session session)
          Attempts to send the given session through the character creation process, at the end of which a character with the given login as name will be in the database, ready to load.
 CharCreationLibrary.LoginSession createLoginSession(Session session)
          Creates a new Login Session for the given Session, which will start the login state machine process that will end eventually with either a disconnect or a character logged in.
 CharCreationLibrary.LoginResult finishLogin(Session session, MOB mob, Room startRoom, boolean resetStats)
          Completes the given session and mobs login by putting the mob into the given start room in the world, checking their email, and seeing if they are allowed in.
 java.lang.String generateRandomName(int minSyllable, int maxSyllable)
          Returns a random fantasy name with the range of syllables given.
 Room getDefaultBodyRoom(MOB mob)
          Given the characteristics of the given mob, this method returns the appropriate morgue room for the given mob.
 Room getDefaultDeathRoom(MOB mob)
          Given the characteristics of the given mob, this method returns the appropriate death room for the given mob.
 Room getDefaultStartRoom(MOB mob)
          Given the characteristics of the given mob, this method returns the appropriate start/recall room for the given mob.
 java.util.List<java.lang.String> getExpiredAcctOrCharsList()
          Returns the list of the names of all the expired Accounts or Characters, depending on whether the account system is used or not.
 int getTotalBonusStatPoints(PlayerStats playerStats, PlayerAccount account)
          Based on the rules of the system, this method returns the number of bonus stat points available to players to allocate, if the system lets them do such a thing.
 int getTrainingCost(MOB mob, int abilityCode, boolean quiet)
          Returns the cost, in trains, for the given mob to gain a point in the given ability code stat number.
 void initBodyRooms(CMProps page)
          Initialize the rules for determining the new character morgue room given the characteristics of the player.
 void initDeathRooms(CMProps page)
          Initialize the rules for determining the new character death room given the characteristics of the player.
 void initStartRooms(CMProps page)
          Initialize the rules for determining the new character start/recall room given the characteristics of the player.
 boolean isAvailableCharClass(CharClass C)
          Returns whether the given character class may be selected by a user.
 boolean isAvailableRace(Race R)
          Returns whether the given race may be selected by a user.
 boolean isBadName(java.lang.String login)
          Returns only whether the given name has a bad word in it.
 boolean isOkName(java.lang.String login, boolean spacesOk)
          Returns whether the given name is a valid, legitimate, unused, unbanned, non-bad name to use in coffeemud, for accounts or players.
 CharCreationLibrary.NewCharNameCheckResult newAccountNameCheck(java.lang.String login, java.lang.String ipAddress)
          Checks whether an account with the given login name from the given ipAddress may be created at this time.
 CharCreationLibrary.NewCharNameCheckResult newCharNameCheck(java.lang.String login, java.lang.String ipAddress, boolean skipAccountNameCheck)
          Checks whether a character with the given login name from the given ipAddress may be created at this time.
 void notifyFriends(MOB mob, java.lang.String message)
          If any of the given mobs friends are online, they are sent the given message.
 boolean performSpamConnectionCheck(java.lang.String address)
          Does a connection spam check against the given address, returning true if all is well, and false if it needs blocking.
 void promptBaseCharStats(int theme, MOB mob, int timeoutSecs, Session session, int bonusPoints)
          A blocking call that populates the given mob with their base CharStats according to character creation rules.
 CharClass promptCharClass(int theme, MOB mob, Session session)
          A blocking call that populates the given mob with a character class according to character creation rules.
 char promptGender(int theme, MOB mob, Session session)
          A blocking call that populates the given mob with a particular gender according to character creation rules.
 Race promptRace(int theme, MOB mob, Session session)
          A blocking call that populates the given mob with a particular race according to character creation rules.
 java.util.List<Race> raceQualifies(int theme)
          Returns the list of all races that the given mob can choose into, given their currrent state, and the given theme.
 void reloadTerminal(MOB mob)
          Resets the MXP, MSP and other session flags based on the mobs attributes.
 void reRollStats(CharStats baseCharStats, int pointsLeft)
          Re-populates the base stats of the given CharStats object by resetting the values to minimum, and then adding as many of the given points to random stats until they are all gone.
 void showTheNews(MOB mob)
          Resets the terminal to the given mobs specs, shows any available polls, the daily message, and runs the MOTD.
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
activate, getServiceClient, L, propertiesLoaded, shutdown
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, ID, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

reRollStats

void reRollStats(CharStats baseCharStats,
                 int pointsLeft)
Re-populates the base stats of the given CharStats object by resetting the values to minimum, and then adding as many of the given points to random stats until they are all gone.

Parameters:
baseCharStats - the charstats object to populate
pointsLeft - the number of points above minimum to allocate
See Also:
CharStats

promptBaseCharStats

void promptBaseCharStats(int theme,
                         MOB mob,
                         int timeoutSecs,
                         Session session,
                         int bonusPoints)
                         throws java.io.IOException
A blocking call that populates the given mob with their base CharStats according to character creation rules. This method might return instantly, or it might send the given session through the stat selection process. The bonusPoints are any over and above the standard allocation points.

Parameters:
theme - the theme code to use for stat allocation
mob - the mob who is getting the new char stats
timeoutSecs - number of seconds before prompt times out
session - the session which might help allocate the points
bonusPoints - any bonus points to allocate to stats
Throws:
java.io.IOException - any input errors that occur
See Also:
CharStats, Area.THEME_FANTASY, reRollStats(CharStats, int), promptCharClass(int, MOB, Session), promptRace(int, MOB, Session), promptGender(int, MOB, Session)

promptCharClass

CharClass promptCharClass(int theme,
                          MOB mob,
                          Session session)
                          throws java.io.IOException
A blocking call that populates the given mob with a character class according to character creation rules. This method might return instantly, or it might send the given session through the class selection process.

Parameters:
theme - the theme code to use for class selection
mob - the mob who is getting the new char class
session - the session which might help allocate the points
Returns:
null or the char class selected
Throws:
java.io.IOException - any input errors that occur
See Also:
CharStats, reRollStats(CharStats, int), promptBaseCharStats(int, MOB, int, Session, int), promptRace(int, MOB, Session), promptGender(int, MOB, Session), Area.THEME_FANTASY

promptRace

Race promptRace(int theme,
                MOB mob,
                Session session)
                throws java.io.IOException
A blocking call that populates the given mob with a particular race according to character creation rules. This method might return instantly, or it might send the given session through the race selection process.

Parameters:
theme - the theme code to use for race selection
mob - the mob who is getting the new race
session - the session which might help get the race
Returns:
the race selected by this process
Throws:
java.io.IOException - any input errors that occur
See Also:
CharStats, reRollStats(CharStats, int), promptBaseCharStats(int, MOB, int, Session, int), promptCharClass(int, MOB, Session), promptGender(int, MOB, Session), Area.THEME_FANTASY

promptGender

char promptGender(int theme,
                  MOB mob,
                  Session session)
                  throws java.io.IOException
A blocking call that populates the given mob with a particular gender according to character creation rules. This method goes through the gender selection process.

Parameters:
theme - the theme code to use for gender selection
mob - the mob who is getting the new gender
session - the session which might help get the gender
Returns:
the gender selected by this process
Throws:
java.io.IOException - any input errors that occur
See Also:
CharStats, reRollStats(CharStats, int), promptBaseCharStats(int, MOB, int, Session, int), promptCharClass(int, MOB, Session), promptRace(int, MOB, Session), Area.THEME_FANTASY

getTrainingCost

int getTrainingCost(MOB mob,
                    int abilityCode,
                    boolean quiet)
Returns the cost, in trains, for the given mob to gain a point in the given ability code stat number.

Parameters:
mob - the mob who is trying to train
abilityCode - the ability code the mob wants to train
quiet - true to not give verbal errors
Returns:
negative number for error, or the number of trains required
See Also:
CharStats

canChangeToThisClass

boolean canChangeToThisClass(MOB mob,
                             CharClass thisClass,
                             int theme)
Returns whether the given mob can change to the given class (that is, to become level 0 in that class) in the given theme. The mob is optional, at which point it is only checking base rules and theme.

Parameters:
mob - null or the mob who wants to learn a new class
thisClass - the class that the mob wants to learn
theme - the theme defining which classes are available
Returns:
true if the mob can change to the class, false otherwise
See Also:
Area.THEME_FANTASY, classQualifies(MOB, int)

classQualifies

java.util.List<CharClass> classQualifies(MOB mob,
                                         int theme)
Returns the list of all character classes that the given mob can change into, given their currrent state, and the given theme. The mob is optional, at which point it is only checking base class rules and theme.

Parameters:
mob - the mob who wants to change classes
theme - the theme to filter the classes by
Returns:
the list of classes that the mob may change to.
See Also:
canChangeToThisClass(MOB, CharClass, int)

getExpiredAcctOrCharsList

java.util.List<java.lang.String> getExpiredAcctOrCharsList()
Returns the list of the names of all the expired Accounts or Characters, depending on whether the account system is used or not. This only matters when the expiration system is being used, such as on a pay system

Returns:
the list of the names of all the expired

isAvailableRace

boolean isAvailableRace(Race R)
Returns whether the given race may be selected by a user.

Parameters:
R - the Race to check
Returns:
true if it's selectable, false otherwise

isAvailableCharClass

boolean isAvailableCharClass(CharClass C)
Returns whether the given character class may be selected by a user.

Parameters:
C - the CharClass to check
Returns:
true if it's selectable, false otherwise

raceQualifies

java.util.List<Race> raceQualifies(int theme)
Returns the list of all races that the given mob can choose into, given their currrent state, and the given theme. The mob is optional, at which point it is only checking base race rules and theme.

Parameters:
theme - the theme to filter the races by
Returns:
the list of races that the mob may choose.
See Also:
canChangeToThisClass(MOB, CharClass, int)

isOkName

boolean isOkName(java.lang.String login,
                 boolean spacesOk)
Returns whether the given name is a valid, legitimate, unused, unbanned, non-bad name to use in coffeemud, for accounts or players.

Parameters:
login - the name to test
spacesOk - true if spaces in the name are ok, false otherwise
Returns:
true if the name is ok, false otherwise
See Also:
isBadName(String), isOkName(String, boolean), newCharNameCheck(String, String, boolean), newAccountNameCheck(String, String)

isBadName

boolean isBadName(java.lang.String login)
Returns only whether the given name has a bad word in it.

Parameters:
login - the name to test
Returns:
true if it has a bad name, false otherwise
See Also:
isOkName(String, boolean), newCharNameCheck(String, String, boolean), newAccountNameCheck(String, String)

newCharNameCheck

CharCreationLibrary.NewCharNameCheckResult newCharNameCheck(java.lang.String login,
                                                            java.lang.String ipAddress,
                                                            boolean skipAccountNameCheck)
Checks whether a character with the given login name from the given ipAddress may be created at this time.

Parameters:
login - the name to check
ipAddress - the ip address of the name checker
skipAccountNameCheck - true to ignore account name matches
Returns:
the results of the new character name check.
See Also:
isBadName(String), isOkName(String, boolean), newAccountNameCheck(String, String), CharCreationLibrary.NewCharNameCheckResult

newAccountNameCheck

CharCreationLibrary.NewCharNameCheckResult newAccountNameCheck(java.lang.String login,
                                                               java.lang.String ipAddress)
Checks whether an account with the given login name from the given ipAddress may be created at this time.

Parameters:
login - the name to check
ipAddress - the ip address of the name checker
Returns:
the results of the new account name check.
See Also:
isBadName(String), isOkName(String, boolean), newCharNameCheck(String, String, boolean)

reloadTerminal

void reloadTerminal(MOB mob)
Resets the MXP, MSP and other session flags based on the mobs attributes. Typically done at sign-on only.

Parameters:
mob - the mob whose session needs to match his
See Also:
showTheNews(MOB)

showTheNews

void showTheNews(MOB mob)
Resets the terminal to the given mobs specs, shows any available polls, the daily message, and runs the MOTD.

Parameters:
mob - the mob to show these things to
See Also:
reloadTerminal(MOB)

notifyFriends

void notifyFriends(MOB mob,
                   java.lang.String message)
If any of the given mobs friends are online, they are sent the given message.

Parameters:
mob - the mob whose friends need notifying
message - the message to send to the mobs friends.

createCharacter

CharCreationLibrary.LoginResult createCharacter(java.lang.String login,
                                                Session session)
                                                throws java.io.IOException
Attempts to send the given session through the character creation process, at the end of which a character with the given login as name will be in the database, ready to load.

Parameters:
login - the name of the new character
session - the session of the character creating person
Returns:
the results of the effort
Throws:
java.io.IOException - an i/o error with the telnet session
See Also:
CharCreationLibrary.LoginResult

initStartRooms

void initStartRooms(CMProps page)
Initialize the rules for determining the new character start/recall room given the characteristics of the player.

Parameters:
page - the properties containing info about the start rooms
See Also:
initDeathRooms(CMProps), initBodyRooms(CMProps), getDefaultStartRoom(MOB)

initDeathRooms

void initDeathRooms(CMProps page)
Initialize the rules for determining the new character death room given the characteristics of the player.

Parameters:
page - the properties containing info about the death rooms
See Also:
initStartRooms(CMProps), initBodyRooms(CMProps), getDefaultDeathRoom(MOB)

initBodyRooms

void initBodyRooms(CMProps page)
Initialize the rules for determining the new character morgue room given the characteristics of the player.

Parameters:
page - the properties containing info about the morgue rooms
See Also:
initStartRooms(CMProps), initDeathRooms(CMProps), getDefaultBodyRoom(MOB)

getDefaultStartRoom

Room getDefaultStartRoom(MOB mob)
Given the characteristics of the given mob, this method returns the appropriate start/recall room for the given mob.

Parameters:
mob - the mob who needs to know their start room
Returns:
the start room for the given mob
See Also:
initStartRooms(CMProps), getDefaultDeathRoom(MOB), getDefaultBodyRoom(MOB)

getDefaultDeathRoom

Room getDefaultDeathRoom(MOB mob)
Given the characteristics of the given mob, this method returns the appropriate death room for the given mob.

Parameters:
mob - the mob who needs to know their death room
Returns:
the death room for the given mob
See Also:
initDeathRooms(CMProps), getDefaultStartRoom(MOB), getDefaultBodyRoom(MOB)

getDefaultBodyRoom

Room getDefaultBodyRoom(MOB mob)
Given the characteristics of the given mob, this method returns the appropriate morgue room for the given mob.

Parameters:
mob - the mob who needs to know their morgue room
Returns:
the morgue room for the given mob
See Also:
initBodyRooms(CMProps), getDefaultStartRoom(MOB), getDefaultDeathRoom(MOB)

getTotalBonusStatPoints

int getTotalBonusStatPoints(PlayerStats playerStats,
                            PlayerAccount account)
Based on the rules of the system, this method returns the number of bonus stat points available to players to allocate, if the system lets them do such a thing.

Parameters:
playerStats - The player stats object for the player
account - the player account object for the player, if applicable
Returns:
the number of stat points available to allocate

generateRandomName

java.lang.String generateRandomName(int minSyllable,
                                    int maxSyllable)
Returns a random fantasy name with the range of syllables given.

Parameters:
minSyllable - the minimum number of syllables, at least 1
maxSyllable - the maximum number of syllables, at least minimum
Returns:
a random fansty name

finishLogin

CharCreationLibrary.LoginResult finishLogin(Session session,
                                            MOB mob,
                                            Room startRoom,
                                            boolean resetStats)
                                            throws java.io.IOException
Completes the given session and mobs login by putting the mob into the given start room in the world, checking their email, and seeing if they are allowed in.

Parameters:
session - the session trying to login
mob - the mob trying to log in
startRoom - the room they will appear in
resetStats - true to reset their state (hit points, etc) or false to keep as-was
Returns:
the LoginResult status of having tried to complete their login
Throws:
java.io.IOException - any I/O errors during the process
See Also:
CharCreationLibrary.LoginResult

performSpamConnectionCheck

boolean performSpamConnectionCheck(java.lang.String address)
Does a connection spam check against the given address, returning true if all is well, and false if it needs blocking.

Parameters:
address - the address to check
Returns:
true to proceed, false to block

completePlayerLogin

CharCreationLibrary.LoginResult completePlayerLogin(Session session,
                                                    boolean wizi)
                                                    throws java.io.IOException
Takes the given session and mobs login by putting the mob into the given start room in the world, checking their email, and seeing if they are allowed in. It does the complete login

Parameters:
session - the session trying to login, with the mob to login
wizi - true if the player should login wizinvisible
Returns:
the LoginResult status of having tried to complete their login
Throws:
java.io.IOException - any I/O errors during the process

createLoginSession

CharCreationLibrary.LoginSession createLoginSession(Session session)
Creates a new Login Session for the given Session, which will start the login state machine process that will end eventually with either a disconnect or a character logged in.

Parameters:
session - the telnet session trying to login
Returns:
the new session object, giving all necessary access to the login state machine.