libchess/pkg/game/game.go

39 lines
647 B
Go
Raw Normal View History

package game
import (
"fmt"
"code.c-base.org/gochess/libchess/pkg/board"
"code.c-base.org/gochess/libchess/pkg/fen"
)
// Tag serves as data-container for game tags.
type Tag struct {
Key string
Value string
}
// Game represents a game of chess.
type Game struct {
Tags []Tag
Board *board.Board
Moves []*board.Move
}
// NewGame returns an initialized game.
func NewGame() *Game {
b, err := fen.Import(fen.DefaultSetup)
if err != nil {
panic(err)
}
return &Game{
Tags: []Tag{},
Board: b,
Moves: []*board.Move{},
}
}
func (g Game) String() string {
return fmt.Sprintf("<Game(Tags: %q, Moves: %q)>", g.Tags, g.Moves)
}