simulation

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCharacterNotFound means that an attempt was made to act on a character that does not exist
	ErrCharacterNotFound = errors.New("character not found")
	// ErrCharacterAwake is thrown when trying to wake a woke character
	ErrCharacterAwake = errors.New("character is awake")
	// ErrCharacterAsleep is thrown when trying do anything other than wake up a sleeping character
	ErrCharacterAsleep = errors.New("character is asleep")
	// ErrRoomNotFound means that an attempt was made to act on a room that does not exist
	ErrRoomNotFound = errors.New("room not found")
)

Functions

This section is empty.

Types

type CharacterController

type CharacterController interface {
	WakeUpCharacter(model.CharacterID) (<-chan interface{}, error)
	SleepCharacter(model.CharacterID) error
	Look(id model.CharacterID) error
	Say(id model.CharacterID, content string) error
}

CharacterController is an interface over the Simulation that exposes all actions a connected player will need to perform

type RegistrationController

type RegistrationController interface {
	MakeCharacter(name string) model.CharacterID
}

RegistrationController is an interface on Simulation that can be used to create new character for new accounts

type Simulation

type Simulation struct {
	// contains filtered or unexported fields
}

Simulation is the engine of the world. It holds rooms, characters, items etc... It exposes a number of interfaces to manipulate the simulation.

func NewSimulation

func NewSimulation(logger *zap.Logger) *Simulation

NewSimulation returns a Simulation with default params.

func (*Simulation) Look added in v0.0.2

func (s *Simulation) Look(id model.CharacterID) error

Look gives the character a room description

func (*Simulation) MakeCharacter

func (s *Simulation) MakeCharacter(name string) model.CharacterID

MakeCharacter creates a new character at the next available ID It returns the new character's ID

func (*Simulation) MakeRoom

func (s *Simulation) MakeRoom(name, description string) model.RoomID

MakeRoom creates a new room at the next available ID

func (*Simulation) Say added in v0.0.2

func (s *Simulation) Say(id model.CharacterID, content string) error

Say allows a character to speak to everyone in the same room

func (*Simulation) SetSpawnRoom

func (s *Simulation) SetSpawnRoom(id model.RoomID) error

SetSpawnRoom sets the room that all new characters will start in

func (*Simulation) SleepCharacter

func (s *Simulation) SleepCharacter(id model.CharacterID) error

SleepCharacter sets a character to sleeping. It sends a character sleeping event to all other characters in the room.

func (*Simulation) WakeUpCharacter

func (s *Simulation) WakeUpCharacter(id model.CharacterID) (<-chan interface{}, error)

WakeUpCharacter make a character wake up. It sends a room description to the waking character. It sends a character waking event to the other characters in the room.

type WorldController

type WorldController interface {
	MakeRoom(name, description string) model.RoomID
	SetSpawnRoom(id model.RoomID) error
}

WorldController is an interface over Simulation for modifying the world itself

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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