model

package
v0.0.0-...-043cf72 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

type Board struct {
	GameID         string
	Rows           [3]Row
	NextPlayerTurn Player
	NextPlayerXorO XORO
	PlayerNames    PlayerNames
	Winner         *Player
}

func CreateNewBoard

func CreateNewBoard(player1Name, player2Name string, gameID string) *Board

func (*Board) TakeTurn

func (g *Board) TakeTurn(row int, col int) (winner *int, cell *Cell, err error)

type BroadcastChannel

type BroadcastChannel chan BroadcastChannelStruct

type BroadcastChannelStruct

type BroadcastChannelStruct struct {
	GameID      string `json:"gameID"`
	UpdatedCell *Cell  `json:"updatedCell"`
}

type Cell

type Cell struct {
	// I set this as a pointer so that I can check if it is nil or not
	Value *CellValue
	Row   int `json:"row"`
	Col   int `json:"col"`
}

type CellValue

type CellValue struct {
	Owner Player
	XorO  XORO
}

type Player

type Player = int
const (
	Player1 Player = 1
	Player2 Player = 2
)

type PlayerNames

type PlayerNames struct {
	Player1 string
	Player2 string
}

type Row

type Row [3]Cell

type XORO

type XORO string
const O XORO = "o"
const X XORO = "x"

func (XORO) String

func (x XORO) String() string

Jump to

Keyboard shortcuts

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