core

package
v0.0.0-...-4797095 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package core contains the main operations for the game engine

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterWS

func RegisterWS(gameId, playerId uuid.UUID, conn *websocket.Conn) error

func StartCleaner

func StartCleaner()

StartCleaner starts the process that cleans up unfinished games

Types

type ConnectRequest

type ConnectRequest struct {
	GameName      string
	Token         string
	NoOfPlayers   int
	PlayerName    string
	EventCallback *url.URL
	TotalRounds   int
}

ConnectRequest is the input for the Connect operation in the core

type ConnectResponse

type ConnectResponse struct {
	GameID uuid.UUID
	Player Player
	Rounds int
}

ConnectResponse is the output for the Connect operation in the core

func Connect

func Connect(req ConnectRequest) (ConnectResponse, error)

Connect tries to connect a new user to a game specified by the token

type PlayRequest

type PlayRequest struct {
	GameID   uuid.UUID
	PlayerID uuid.UUID
	Round    int
	Move     interface{}
}

PlayRequest is the input for the Play operation in the core

type PlayResponse

type PlayResponse struct {
	Round       int
	PlayersMove []string
}

PlayResponse is the output for the Play operation in the core

func Play

func Play(req PlayRequest) (PlayResponse, error)

Play processes a given player's move in a given round in a specific game

type Player

type Player struct {
	ID            uuid.UUID
	Name          string
	EventCallback *url.URL
	WebsocketConn *websocket.Conn
	// contains filtered or unexported fields
}

Player holds data of a player in the context of a Connect operation

Directories

Path Synopsis
Package events is responsible for notifying clients
Package events is responsible for notifying clients
Package games contains all the supported games
Package games contains all the supported games

Jump to

Keyboard shortcuts

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