frontend

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2019 License: BSD-2-Clause Imports: 23 Imported by: 0

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 and processing their responses. These pages cover logging into the server, 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(log log.Conn, output io.Writer) *frontend

New returns an initialised instance of frontend. The passed log.Conn is used by the instance for per-connection logging. The io.Writer is used to write data back to the client. The instance is also setup with greetingDisplay as the nextFunc to call.

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 NewGame

func NewGame(f *frontend) (g *game)

NewGame returns a game with the specified frontend embedded. The returned game can be used for processing communication to the actual game.

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 NewMenu

func NewMenu(f *frontend) (m *menu)

NewMenu returns a menu with the specified frontend embedded. The returned menu can be used for processing the main menu and it's options.

func Zero added in v0.0.6

func Zero(data []byte)

Zero writes zero bytes into the passed slice

Types

This section is empty.

Notes

Bugs

  • write should return any errors so that they can be checked. At the moment if there is an error writing the player file the player is still let in and their details not saved for next time they log in.

  • assemblePlayer is very fragile and makes assumptions. For example it assumes jar[0] (the first record) is for the player.

  • Need to add error handling for unexpected/missing fields.

Source Files

  • account.go
  • frontend.go
  • game.go
  • login.go
  • menu.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL