coordinator

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

README

tome_server

Tomecraft library that wraps up the engine into something that can be useful.

Tome_server handles the matchmaking and server-side game management; it does not

  • Have the rules engine (that's in tome_game)
  • Handle networking
  • Provide an actual running server

However this combined with a networking frontend (i.e. tome_ws) will give you a full game server.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchCleaner

func MatchCleaner(c *Coordinator)

func MatchMaker

func MatchMaker(c *Coordinator)

func MatchWatcher

func MatchWatcher(m *Session)

func QueueCleaner

func QueueCleaner(c *Coordinator)

Types

type Coordinator

type Coordinator struct {
	Matches         map[uuid.UUID]*Session
	MatchLock       *sync.Mutex
	PlayerQueueChan chan uuid.UUID
	PlayerPool      map[MMRPlayer]bool
	CallbackChan    map[uuid.UUID]chan uuid.UUID
}

func NewCoordinator

func NewCoordinator() *Coordinator

func (*Coordinator) Coordinate

func (c *Coordinator) Coordinate(cmd *SessionCommand) *SessionCommandResult

func (*Coordinator) Start

func (c *Coordinator) Start()

type MMRPlayer

type MMRPlayer struct {
	Id        uuid.UUID
	MMR       int
	QueueTime time.Time
}

type Session

type Session struct {
	ID uuid.UUID

	Active     bool
	Game       *Game
	Watcher    chan bool
	Broadcasts map[uuid.UUID]chan SessionResp
	LastMove   time.Time
	// contains filtered or unexported fields
}

func NewSession

func NewSession() *Session

func (*Session) Join

func (s *Session) Join(id uuid.UUID) SessionResp

func (*Session) Leave

func (s *Session) Leave(id uuid.UUID)

func (*Session) Play

func (s *Session) Play(id uuid.UUID, cmd *Command) *CommandResult

func (*Session) PlayerIn

func (s *Session) PlayerIn(id uuid.UUID) bool

type SessionCommand

type SessionCommand struct {
	ID          uuid.UUID  `json:"player_id"`
	MatchID     uuid.UUID  `json:"match_id"`
	Command     SessionCmd `json:"command"`
	GameCommand *Command   `json:"game_command,omitempty"`
}

func (*SessionCommand) String

func (s *SessionCommand) String() string

type SessionCommandResult

type SessionCommandResult struct {
	ID         uuid.UUID      `json:"player_id"`
	MatchID    uuid.UUID      `json:"match_id"`
	Result     SessionResp    `json:"result"`
	GameResult *CommandResult `json:"game_result,omitempty"`
}

func (*SessionCommandResult) String

func (s *SessionCommandResult) String() string

Jump to

Keyboard shortcuts

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