razchess

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultKillTimeout = time.Hour
View Source
const (
	StartingFEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
)

Variables

This section is empty.

Functions

func GenerateFischerRandomFEN added in v1.6.1

func GenerateFischerRandomFEN() string

func GenerateID added in v1.2.1

func GenerateID(length int) string

func GetInternalPuzzles added in v1.2.1

func GetInternalPuzzles() []string

func MoveHistoryToGIF added in v1.6.1

func MoveHistoryToGIF(w io.Writer, moves []*chess.Move, positions []*chess.Position) error

Types

type DB

type DB redis.Client

func NewDB

func NewDB(redisURL string) (*DB, error)

func (*DB) LoadSessions

func (db *DB) LoadSessions() map[string]string

func (*DB) SaveSession

func (db *DB) SaveSession(room, game string, expiration time.Duration)

type Move added in v1.3.1

type Move [2]string

type Server

type Server struct {
	http.ServeMux
	// contains filtered or unexported fields
}

func NewServer

func NewServer(assets fs.FS, mgr *SessionMgr, puzzles []string) *Server

type Session

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

func (*Session) Move

func (sess *Session) Move(move string, validMove *bool) error

Session.Move is an RPC function that handles a move in [from][to] format (like e2e4)

func (*Session) Resign added in v1.6.1

func (sess *Session) Resign(color string, unused *bool) error

Session.Resign is an RPC function that allows a color to resign

type SessionMgr

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

func NewSessionMgr

func NewSessionMgr(redisURL string, killTimeout time.Duration) *SessionMgr

func (*SessionMgr) CreateSession added in v1.3.1

func (mgr *SessionMgr) CreateSession(game string) (string, error)

func (*SessionMgr) MoveHistoryToGIF added in v1.6.1

func (mgr *SessionMgr) MoveHistoryToGIF(w io.Writer, roomID string) error

func (*SessionMgr) ServeRPC added in v1.6.1

func (mgr *SessionMgr) ServeRPC(w http.ResponseWriter, r *http.Request, roomID string)

type Update

type Update struct {
	Move          Move   `json:"move,omitempty"`
	Turn          string `json:"turn"`
	Status        string `json:"status"`
	FEN           string `json:"fen,omitempty"`
	PGN           string `json:"pgn,omitempty"`
	Opening       string `json:"opening,omitempty"`
	IsCapture     bool   `json:"isCapture"`
	IsGameOver    bool   `json:"isGameOver"`
	CheckedSquare string `json:"checkedSquare,omitempty"`
}

Jump to

Keyboard shortcuts

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