Documentation ¶
Overview ¶
Package frontend provides interactive processing of front end pages and access to the backend game. Note that a 'page' can be anything from a menu of options to choose from to a simple request for a password.
The frontend is responsible for coordinating the display of pages to a user account creation, player creation and other non in-game activities. When the player is in-game the frontend will simply pass any input through to the game backend for processing.
Pages typically have a pair of methods - a display part and a processing part. For example accountDisplay and accountProcess. Sometimes there is only a display part, for example greetingDisplay.
The current state is held in an instance of frontend. With frontend.nextFunc being the next method to call when input is received - usually an xxxProcess method.
Each time input is received Parse will be called. The method in nextFunc will be called to handle the input. nextFunc should then call the next xxxDisplay method to send a response to the input processing and setup nextFunc with the method that will process the next input received. Any buffered response will then be sent back before Parse exits. Parse will then be called again when more input is received.
Index ¶
- func FirstTimeStartGame(f *frontend, charName string) (g *game)
- func New(output io.Writer, address string, errorWriter func(error), clientclose func()) *frontend
- func NewCharacter(f *frontend) (a *newCharacter)
- func NewLogin(f *frontend) (l *login)
- func NewPCharacter(f *frontend) (a *newPCharacter)
- func NewStart(f *frontend) (m *start)
- func ResumeGame(f *frontend, charRef *objects.Character) (g *game)
- func StartGame(f *frontend, charName string) (g *game)
- func Zero(data []byte)
- type Account
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstTimeStartGame ¶
func FirstTimeStartGame(f *frontend, charName string) (g *game)
func New ¶
New returns an instance of frontend initialised with the given io.Writer. The io.Writer is used to send responses back from calling Parse. The new frontend is initialised with a message buffer and nextFunc setup to call greetingDisplay.
func NewCharacter ¶
func NewCharacter(f *frontend) (a *newCharacter)
func NewLogin ¶
func NewLogin(f *frontend) (l *login)
NewLogin returns a login with the specified frontend embedded. The returned login can be used for processing the logging in of accounts.
func NewPCharacter ¶
func NewPCharacter(f *frontend) (a *newPCharacter)
func ResumeGame ¶
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account embeds a frontend instance adding fields and methods specific to
func NewAccount ¶
func NewAccount(f *frontend) (a *Account)
NewAccount returns an account with the specified frontend embedded. The returned account can be used for processing the creation of new accounts and players.
func (Account) AccountCleanup ¶
func (f Account) AccountCleanup()
func (Account) Close ¶
func (f Account) Close()
Close makes sure the player is no longer 'in game' and frees up resources
func (Account) Disconnect ¶
func (f Account) Disconnect()
func (Account) GetCharacter ¶
func (Account) Parse ¶
Parse is the main input/output processing method for frontend. The input is stripped of leading and trailing whitespace before being stored in the frontend state. Any response from processing the input is written to the io.Writer passed to the initial New function that created the frontend. If the frontend is closed during processing a frontend.Error will be returned else nil.