server

package
v0.0.0-...-d5d5497 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

README

Morogue Server

The morogue server supplies an HTTP and WebSockets server. The websockets server interfaces with a running morogue universe.

A universe contains:

  • accounts
    • characters
  • worlds
    • locations

The universe handles creating accounts and worlds. If a client has selected a character and either creates or joins a world, the client is sent to the world and thereafter the world handles all network communication. Once the world is done with the client, it sends it back to the universe to be managed by it or to be removed by it.

An account is a user-created account. Each account can store multiple characters. These characters are saved between worlds unless a permadeath server is chosen.

A world is a goroutine that contains locations and clients. Each location contains characters, mobs, objects, and, of course, the cells that make up a location. In more traditional terms, a world is a self-contained game state, and a location is a map or level.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotLoggedIn           = errors.New("not logged in")
	ErrBadPassword           = errors.New("bad password")
	ErrCharacterExists       = errors.New("character exists")
	ErrCharacterDoesNotExist = errors.New("character does not exist")
	ErrNoSuchArchetype       = errors.New("no such archetype")
)
View Source
var (
	ErrNoUser     = errors.New("no such user")
	ErrUserExists = errors.New("user exists")
)
View Source
var (
	ErrCharacterNotInLocation         = errors.New("character is not in location")
	ErrCharacterAlreadyInLocation     = errors.New("character is already in location")
	ErrCharacterCannotPlaceInLocation = errors.New("character cannot be placed in location")
)
View Source
var (
	ErrWrongState        = errors.New("message sent in wrong state")
	ErrTooSoon           = errors.New("message sent too soon, please wait and try again")
	ErrNotJoined         = errors.New("character not joined")
	ErrAlreadyJoined     = errors.New("character is already joined")
	ErrUserLoggedIn      = errors.New("user is logged in")
	ErrWorldDoesNotExist = errors.New("world does not exist")
)
View Source
var (
	ErrMovementBlocked = errors.New("movement blocked")
)

Functions

func NewAccounts

func NewAccounts(path string) (*accounts, error)

func NewSocketServer

func NewSocketServer(newClientChan chan client, checkChan chan struct{}) *socketServer

func NewUniverse

func NewUniverse(accounts Accounts, data *Data) (universe, chan client, chan struct{})

Types

type Account

type Account struct {
	ID         int
	Characters []*game.Character
	Password   string
	// contains filtered or unexported fields
}

Account is a user account that contains a password and a list of characters.

func (*Account) CreateCharacter

func (a *Account) CreateCharacter(name string, archetype id.UUID) (*game.Character, error)

CreateCharacter creates a character with the name and archetype.

func (*Account) DeleteCharacter

func (a *Account) DeleteCharacter(name string) error

DeleteCharacter deletes a given character by name.

func (*Account) HasCharacter

func (a *Account) HasCharacter(name string) bool

HasCharacter returns of the account has the given character by name.

func (*Account) PasswordMatches

func (a *Account) PasswordMatches(password string) bool

PasswordMatches returns if the given password matches the stored hashed password.

type Accounts

type Accounts interface {
	Account(username string) (account Account, err error)
	NewAccount(username string, password string) error
	SaveAccount(account Account) error
	Buckets() (buckets []string)
	ListBucket(bucket string) (list []string)
	DumpBytes(bucket, data string) []byte
}

Accounts is an interface for loading, creating, and saving accounts.

type Appliable

type Appliable interface {
	Apply()
	Unapply()
	IsApplied() bool
}

type Blockable

type Blockable interface {
	IsBlocked() bool
}

type Damager

type Damager interface {
	CalculateFromCharacter(c *game.Character)
	RollDamages() []game.DamageResult
}

type Data

type Data struct {
	Archetypes []game.Archetype
	Places     Places
	Fixtures   Fixtures
}

func (*Data) Archetype

func (d *Data) Archetype(uuid id.UUID) game.Archetype

func (*Data) ArmorArchetypes

func (d *Data) ArmorArchetypes() []game.ArmorArchetype

func (*Data) CharacterArchetypes

func (d *Data) CharacterArchetypes() []game.CharacterArchetype

func (*Data) ItemArchetypes

func (d *Data) ItemArchetypes() []game.ItemArchetype

func (*Data) LoadArchetypes

func (d *Data) LoadArchetypes() error

func (*Data) LoadFixtures

func (d *Data) LoadFixtures() error

func (*Data) LoadPlaces

func (d *Data) LoadPlaces() error

func (*Data) Tile

func (d *Data) Tile(uuid id.UUID) (game.TileArchetype, error)

func (*Data) TileArchetypes

func (d *Data) TileArchetypes() []game.TileArchetype

func (*Data) WeaponArchetypes

func (d *Data) WeaponArchetypes() []game.WeaponArchetype

type Fixtures

type Fixtures []gen.Fixture

func (Fixtures) ById

func (f Fixtures) ById(uid id.UUID) (gen.Fixture, error)

type Hurtable

type Hurtable interface {
	CalculateFromObject(o game.Object)
	TakeDamages(damages []game.DamageResult)
	TakeHeal(heal int)
	IsDead() bool
}

type Lockable

type Lockable interface {
	Lock()
	Unlock()
	IsLocked() bool
}

type Openable

type Openable interface {
	IsOpened() bool
	Open() error
	Close() error
}

type Places

type Places []gen.Place

func (Places) ById

func (p Places) ById(uid id.UUID) (gen.Place, error)

Jump to

Keyboard shortcuts

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