game

package
v0.0.0-...-d89176e Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

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

Game represents the current context of a tic tac toe game Its has board information and all the relevant players in the game

func NewGame

func NewGame(b *board.Board, playerOne player.Player, playerTwo player.Player) *Game

NewGame returns a new Game

func (*Game) Start

func (g *Game) Start()

Start is the entry point for the game Its a blocking call, terminates when users wishes to not play any more It switches between two players

func (*Game) Status

func (g *Game) Status() Status

Status returns the current status of the game It validates the board horizontally, vertically and diagonally If there is a winner, it returns it else returns the state of the board

func (*Game) String

func (g *Game) String() string

String returns the string representation of the board

type Status

type Status string
var (
	Draw       Status = "Draw"
	InProgress Status = "In Progress"
	XPlayerWon Status = "Player X Won"
	OPlayerWon Status = "Player O Won"
)

Jump to

Keyboard shortcuts

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