tictactoe

package
v0.0.0-...-c3821dc Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Draw

type Draw struct{}

Draw is when either X now O won

type Game

type Game struct {
	aggregate.Root
	// contains filtered or unexported fields
}

func NewGame

func NewGame() *Game

Constructor

func (*Game) Done

func (g *Game) Done() bool

func (*Game) PlayMove

func (g *Game) PlayMove(x, y int) error

Commands

func (*Game) Register

func (g *Game) Register(f aggregate.RegisterFunc)

Register is used to register the events and the aggregate to the internal register.

func (*Game) Render

func (g *Game) Render()

Render prints the board

func (*Game) Transition

func (g *Game) Transition(event eventsourcing.Event)

Transition is an method to transform events to game state. The state is then used to uphold the rules of the game. This method is needed for the Game to be an aggregate and be used by the functions in the aggregate package.

func (*Game) Turn

func (g *Game) Turn() string

Query methods

func (*Game) Winner

func (g *Game) Winner() string

type OMoved

type OMoved struct {
	X int
	Y int
}

OMoved then the O player moved togheter with the cordinates.

type OWon

type OWon struct{}

OWon is the last event when O is the winner

type Started

type Started struct{}

Started indicates that the game has started

type XMoved

type XMoved struct {
	X int
	Y int
}

XMoved then the X player moved togheter with the cordinates.

type XWon

type XWon struct{}

XWon is the last event when X is the winner

Directories

Path Synopsis
cmd
main command

Jump to

Keyboard shortcuts

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