game

package
v0.0.0-...-5c15ff0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotSwapTiles = errors.New(
	"swapping tiles is only allowed in game clones created with DeepCloneWithSwappableTiles()",
)

Functions

func NewBoard

func NewBoard(tileSet tilesets.TileSet) elements.Board

Types

type Game

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

func NewFromDeck

func NewFromDeck(
	deck deck.Deck, log logger.Logger,
) (*Game, error)

func NewFromTileSet

func NewFromTileSet(tileSet tilesets.TileSet, log logger.Logger) (*Game, error)

func (*Game) CanSwapTiles

func (game *Game) CanSwapTiles() bool

func (*Game) CurrentPlayer

func (game *Game) CurrentPlayer() elements.Player

func (Game) DeepClone

func (game Game) DeepClone() *Game

func (*Game) DeepCloneWithLog

func (game *Game) DeepCloneWithLog(log logger.Logger) (*Game, error)

func (*Game) DeepCloneWithSwappableTiles

func (game *Game) DeepCloneWithSwappableTiles() *Game

func (*Game) Finalize

func (game *Game) Finalize() (elements.ScoreReport, error)

func (*Game) GetCurrentTile

func (game *Game) GetCurrentTile() (tiles.Tile, error)

func (*Game) GetLegalMovesFor

func (game *Game) GetLegalMovesFor(placement elements.PlacedTile) []elements.PlacedTile

func (*Game) GetMidGameScore

func (game *Game) GetMidGameScore() elements.ScoreReport

Calculate points as if game has just finished

func (*Game) GetRemainingTiles

func (game *Game) GetRemainingTiles() []tiles.Tile

func (*Game) GetTilePlacementsFor

func (game *Game) GetTilePlacementsFor(tile tiles.Tile) []elements.PlacedTile

func (*Game) PlayTurn

func (game *Game) PlayTurn(move elements.PlacedTile) error

func (*Game) PlayerCount

func (game *Game) PlayerCount() int

func (*Game) Serialized

func (game *Game) Serialized() SerializedGame

func (*Game) SwapCurrentTile

func (game *Game) SwapCurrentTile(tile tiles.Tile) error

type SerializedGame

type SerializedGame struct {
	CurrentTile         tiles.Tile
	ValidTilePlacements []elements.PlacedTile
	CurrentPlayerID     elements.ID
	Players             []elements.SerializedPlayer
	PlayerCount         int
	Tiles               []elements.PlacedTile
	TileSet             tilesets.TileSet
	BinaryTiles         []binarytiles.BinaryTile // contains info about all placed tiles, not placed tiles are equal to 0
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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