Class Account
In: lib/core/account.rb
Parent: Root
Account
Publisher
Root
TopLevel

The Account class handles connection login and passes them to character.

Methods

Included Modules

Publisher

Attributes

character  [RW] 
conn  [RW] 
echo  [RW] 
mode  [RW] 
terminal  [RW] 
termsize  [RW] 

Public Class methods

Create an Account connection. This is a temporary object that handles login for character and gets them connected.

conn
The session associated with this Account connection.
return
A handle to the Account object.

Public Instance methods

If echo hasn’t been negotiated, we want to leave the cursor after the message prompt, so we prepend linefeeds in front of messages. This is hackish.

Disconnects this account

Handles message while in the login menu - called by parse_messages. This was refactored out of Account#parse_messages for length reasons.

msg
The message string

@mode tracks the state changes, This routine is entered by any @modes staring with :menu.

The following state transition diagram illustrates the possible transitions.

:menu -> :menucr Create a character

           -> :menupl       Play a character

:menucr -> :playing Get character name, create character and play

Handles String messages from Connection - called by update. This was refactored out of Account#update for length reasons.

msg
The message string

@mode tracks the state changes, The Account is created with the initial state of :initialize. The following state transition diagram illustrates the possible transitions.

:intialize -> :name Set when Account:update receives :initdone msg :name -> :password Sets @login_name and finds @account

              :playing      Creates a new character if Guest account

:password -> :newacct Sets @login_passwd

           -> :menu         Good passwd, switches account, if account_system
                            option on goes to menu
           -> :playing      Good passwd, switches account, loads character
           -> :name         Bad passwd
           -> disconnect    Bad passwd, exceeds @check attempts
                            (see Account#disconnect)

:newacct -> :menu If account_system option on goes to menu

           -> :playing        Creates new character, adds account

:menu -> parse_menu Redirect message (see Account#parse_menu) :playing -> @character Redirect message (see Character#parse)

Receives messages from a Connection being observed and handles login state.

msg
The message string

This supports the following:

:disconnected
- This symbol from the server informs us that the Connection has disconnected.
:initdone
- This symbol from the server indicates that the Connection
  is done setting up and done negotiating an initial state.
  It triggers us to start sending output and parsing input.
:termsize
- This is sent everytime the terminal size changes (NAWS)
String
- A String is assumed to be input from the Session and we
  send it to parse_messages.

[Validate]