controller

package
v0.0.0-...-c857007 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package controller has the ui game logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {
	Socket Socket
	// contains filtered or unexported fields
}

Game handles managing the state of the board and drawing it on the canvas.

func NewGame

func NewGame(board *board.Board, canvas *canvas.Canvas) Game

NewGame creates a new game controller with references to the board and canvas.

func (*Game) Create

func (g *Game) Create()

Create clears the tiles and asks the server for a new game to join

func (*Game) Delete

func (g *Game) Delete()

Delete removes everyone from the game and deletes it.

func (*Game) Finish

func (g *Game) Finish()

Starts triggers the game to finish for everyone by checking the players tiles.

func (*Game) InitDom

func (g *Game) InitDom(ctx context.Context, wg *sync.WaitGroup)

InitDom regesters game dom functions.

func (*Game) Join

func (g *Game) Join(id int)

Join asks the server to join an existing game.

func (*Game) Leave

func (g *Game) Leave()

Leave changes the view for game by hiding it.

func (*Game) SendChat

func (g *Game) SendChat(message string)

SendChat sends a chat message.

func (*Game) SnagTile

func (g *Game) SnagTile()

SnagTile asks the game to give everone a new tile.

func (*Game) Start

func (g *Game) Start()

Starts triggers the game to start for everyone.

func (*Game) UpdateInfo

func (g *Game) UpdateInfo(m game.Message)

UpdateInfo updates the game for the specified message.

type Socket

type Socket interface {
	Send(m game.Message)
}

Socket sends messages to the server.

Jump to

Keyboard shortcuts

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