Documentation ¶
Index ¶
- Variables
- type CharacterController
- type RegistrationController
- type Simulation
- func (s *Simulation) Look(id model.CharacterID) error
- func (s *Simulation) MakeCharacter(name string) model.CharacterID
- func (s *Simulation) MakeRoom(name, description string) model.RoomID
- func (s *Simulation) Say(id model.CharacterID, content string) error
- func (s *Simulation) SetSpawnRoom(id model.RoomID) error
- func (s *Simulation) SleepCharacter(id model.CharacterID) error
- func (s *Simulation) WakeUpCharacter(id model.CharacterID) (<-chan interface{}, error)
- type WorldController
Constants ¶
This section is empty.
Variables ¶
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.