const (
StateLength = iota
StatePlayerScore
StateOpponentScore
StateBoardSpace0
)
const (
StatePlayerName = iota
StateOpponentName
)
const (
StateTurn = 29 + iota
StatePlayerDice1
StatePlayerDice2
StateOpponentDice1
StateOpponentDice2
StateDoublingValue
StatePlayerMayDouble
StateOpponentMayDouble
StateWasDoubled
StatePlayerColor
StateDirection
StateObsoleteHome
StateObsoleteBar
StatePlayerHome
StateOpponentHome
StatePlayerBar
StateOpponentBar
StateMovablePieces
StateObsoletePlayerForced
StateObsoleteOpponentForced
StateRedoubles
)
const (
BoxDrawingsLightVertical = '|'
)
const (
SpaceUnknown = -1
)
var (
TypeWelcome = []byte("1")
TypeOwnInfo = []byte("2")
TypeMOTD = []byte("3")
TypeEndMOTD = []byte("4")
TypeWhoInfo = []byte("5")
TypeEndWhoInfo = []byte("6")
TypeLogin = []byte("7")
TypeLogout = []byte("8")
TypeMsg = []byte("9")
TypeMsgDelivered = []byte("10")
TypeMsgSaved = []byte("11")
TypeSay = []byte("12")
TypeShout = []byte("13")
TypeWhisper = []byte("14")
TypeKibitz = []byte("15")
TypeYouSay = []byte("16")
TypeYouShout = []byte("17")
TypeYouWhisper = []byte("18")
TypeYouKibitz = []byte("19")
TypeBoardState = []byte("board:")
)
var (
StatusWriter io.Writer
GameWriter io.Writer
)
Debug controls the level of debug information to print.
var Debug = 0
var DefaultProxyAddress = ""
type Board struct {
Premovefrom map[int]int
Premoveto map[int]int
sync.Mutex
// contains filtered or unexported fields
}
func NewBoard(client *Client) *Board
func (b *Board) AddPreMove(from int, to int) bool
func (b *Board) Draw()
func (b *Board) GetIntState() []int
func (b *Board) GetPreMoves() [][2]int
func (b *Board) GetSelection() (num int, space int)
func (b *Board) GetState() string
func (b *Board) GetStringState() []string
TODO refactor
func (b *Board) GetValidMoves(from int) [][]int
func (b *Board) Move(player int, f string, t string)
func (b *Board) PlayerBarSpace() int
func (b *Board) PlayerBearOffSpace() int
func (b *Board) PlayerHomeSpaces() (int, int)
func (b *Board) PlayerPieceAreHome() bool
func (b *Board) Render() []byte
func (b *Board) ResetMoves()
func (b *Board) ResetPreMoves()
func (b *Board) ResetSelection()
func (b *Board) SetSelection(num int, space int)
func (b *Board) SetState(state string)
func (b *Board) SimplifyMoves()
func (b *Board) ValidMove(f int, t int) bool
type Client struct {
In chan []byte
Out chan []byte
Event chan interface{}
Username string
Password string
Board *Board
// contains filtered or unexported fields
}
func NewClient(serverAddress string, username string, password string) *Client
func (c *Client) CallTELNET(ctx telnet.Context, w telnet.Writer, r telnet.Reader)
CallTELNET is called when a connection is made with the server.
func (c *Client) Connect() error
func (c *Client) GetAllWhoInfo() []*WhoInfo
func (c *Client) LoggedIn() bool
func (c *Client) WatchRandomGame()
type EventBoardState struct {
S []string
V []int
}
type EventDraw struct{}
type EventMessage struct {
Message string
}
type EventMove struct {
Player int
From int
To int
}
type EventWho struct {
Who []*WhoInfo
}
type WhoInfo struct {
Username string
Opponent string
Watching string
Ready bool
Away bool
Rating int
Experience int
Idle int
LoginTime int
ClientName string
}
func (w *WhoInfo) String() string