frontend

package
v0.0.0-...-5996917 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: Apache-2.0 Imports: 22 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 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 FirstTimeStartGame

func FirstTimeStartGame(f *frontend, charName string) (g *game)

func New

func New(output io.Writer, address string, errorWriter func(error), clientclose func()) *frontend

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 NewStart

func NewStart(f *frontend) (m *start)

func ResumeGame

func ResumeGame(f *frontend, charRef *objects.Character) (g *game)

func StartGame

func StartGame(f *frontend, charName string) (g *game)

func Zero

func Zero(data []byte)

Zero writes zero bytes into the passed slice

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 (f Account) GetCharacter() *objects.Character

func (Account) Parse

func (f Account) Parse(input []byte) error

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.

func (Account) Write

func (f Account) Write(b []byte) (n int, err error)

Write writes the specified byte slice to the associated client.

Jump to

Keyboard shortcuts

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