thordb

package
v0.0.0-...-7b1d17e Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGameFull = errors.New("thordb: game is full")
View Source
var ErrGameNotExist = errors.New("thordb: game does not exist")
View Source
var ErrInvalidMachineKey = errors.New("thordb: invalid machine key")
View Source
var ErrInvalidSessionKey = errors.New("thordb: invalid session key")

errors

View Source
var GameNotExistError = errors.New("thordb: game does not exist")

Functions

func CreateCharacter

func CreateCharacter(sessionKey string, name string, classId int) (int, error)

func CreateNewGame

func CreateNewGame(mapName string, gameMode string, minimumLevel int, maxPlayers int) (int, error)

func Disconnect

func Disconnect(userToken string) error

func GetCharacter

func GetCharacter(machineKey string, characterId int) (*model.Character, error)

func GetGamesList

func GetGamesList() ([]model.Game, error)

func GetMachineList

func GetMachineList() ([]model.Machine, error)

func GetServerInfo

func GetServerInfo(gameId int) (*model.HostServer, bool, error)

func LoginAccount

func LoginAccount(username string, password string) (string, []int, error)

func PlayerConnect

func PlayerConnect(gameId int, machineKey string, sessionKey string, characterId int) (*model.Character, error)

func PlayerDisconnect

func PlayerDisconnect(machineKey string, gameId int, character *model.Character) error

func ProvisionNewGame

func ProvisionNewGame(game_id int, map_name string, game_mode string) error

func ProvisionNewMachine

func ProvisionNewMachine()

func RegisterAccount

func RegisterAccount(username string, password string) (string, []int, error)

func RegisterActiveGame

func RegisterActiveGame(gameId int, machineKey string, listenPort int) error

func RegisterMachine

func RegisterMachine(remoteAddress string, servicePort int) (int, string, error)

func SelectCharacter

func SelectCharacter(sessionKey string, characterId int) (*model.Character, error)

func ShutdownServer

func ShutdownServer(machineKey string, gameId int) error

func StoreCharacterSnapshot

func StoreCharacterSnapshot(charSession *CharacterSession) (bool, error)

ToDo: remove this func from public, only exposed for testing this should be used internally to thordb only!

func TestMachineRequest

func TestMachineRequest()

func UnregisterMachine

func UnregisterMachine(machineToken string) (bool, error)

func UpdateCharacter

func UpdateCharacter(machineKey string, character *model.Character) error

func UpdateMachineStatus

func UpdateMachineStatus(machineToken string, usageCpu float64, usageNetwork float64, usagePlayerCapacity float64) error

Types

type Account

type Account struct {
	UserID         int       `json:"uid"`
	CharacterIDs   []int     `json:"characters"`
	HashedPassword []byte    `json:"hashedPassword"`
	Salt           []byte    `json:"salt"`
	Algorithm      string    `json:"hashAlgorithm"`
	CreatedOn      time.Time `json:"createdOn"`
	LastLogin      time.Time `json:"lastLogin"`
}

func (*Account) NewPublicView

func (account *Account) NewPublicView() AccountPublicView

func (*Account) Validate

func (account *Account) Validate() (bool, error)

type AccountPublicView

type AccountPublicView struct {
	UserID       int       `json:"uid"`
	CharacterIDs []int     `json:"characters"`
	CreatedOn    time.Time `json:"createdOn"`
	LastLogin    time.Time `json:"lastLogin"`
}

type AccountSession

type AccountSession struct {
	UserID int    `json:"uid"`
	Token  string `json:"token"`
	Account
}

type CharacterData

type CharacterData struct {
	Name          string                `json:"name"`
	Soul          int                   `json:"soul"`
	World         generate.Coordinate2D `json:"worldCoord"`
	Position      Vector3               `json:"worldPosition"`
	Weapons       []int                 `json:"weapons"`
	Inventory     []int                 `json:"inventory"`
	Health        float64               `json:"health"`
	Power         float64               `json:"powerLevel"`
	Experience    int                   `json:"experienceLevel"`
	MasteryPoints []int                 `json"masteryPoints"`
}

func NewCharacterData

func NewCharacterData() *CharacterData

type CharacterSession

type CharacterSession struct {
	ID     int    `json:"id"`
	UserID int    `json:"uid"`
	Token  string `json:"charSessionToken"`
	GameId int    `json:"gameId"`
	*CharacterData
}

func NewCharacterSession

func NewCharacterSession() *CharacterSession

func NewCharacterSessionFrom

func NewCharacterSessionFrom(character *CharacterData) *CharacterSession

type Vector3

type Vector3 struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`
}

type World

type World struct {
	ID         int
	CreatedOn  time.Time
	LastUpdate time.Time
	WorldData
}

type WorldData

type WorldData struct {
	Name        string                `json:"worldName"`
	Location    generate.Coordinate2D `json:"worldCoordinate"`
	Soul        int                   `json:"soul"`
	TerrainType int                   `json:"terrainType"`
	GameMode    int                   `json:"gameMode"`
	Players     []CharacterSession    `json:"playerSessions"`
	NPCs        []CharacterData       `json:"nonPlayerCharacters"`
}

Jump to

Keyboard shortcuts

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