...

Package fibs

Overview ▾

Package fibs provides a FIBS.com (online backgammon) client library.

In addition to the standard FIBS commands, the following internal custom commands are available:

- `watch` - Watch a random game - `tv` - Watch random games continuously

Index ▾

Constants
Variables
type Board
    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
    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
    func NewClient(serverAddress string, username string, password string) *Client
    func (c *Client) CallTELNET(ctx telnet.Context, w telnet.Writer, r telnet.Reader)
    func (c *Client) Connect() error
    func (c *Client) GetAllWhoInfo() []*WhoInfo
    func (c *Client) LoggedIn() bool
    func (c *Client) WatchRandomGame()
type EventBoardState
type EventDraw
type EventMessage
type EventMove
type EventWho
type WhoInfo
    func (w *WhoInfo) String() string

Package files

board.go client.go doc.go event.go util.go

Constants

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
)

Variables

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

type Board struct {
    Premovefrom map[int]int
    Premoveto   map[int]int

    sync.Mutex
    // contains filtered or unexported fields
}

func NewBoard

func NewBoard(client *Client) *Board

func (*Board) AddPreMove

func (b *Board) AddPreMove(from int, to int) bool

func (*Board) Draw

func (b *Board) Draw()

func (*Board) GetIntState

func (b *Board) GetIntState() []int

func (*Board) GetPreMoves

func (b *Board) GetPreMoves() [][2]int

func (*Board) GetSelection

func (b *Board) GetSelection() (num int, space int)

func (*Board) GetState

func (b *Board) GetState() string

func (*Board) GetStringState

func (b *Board) GetStringState() []string

TODO refactor

func (*Board) GetValidMoves

func (b *Board) GetValidMoves(from int) [][]int

func (*Board) Move

func (b *Board) Move(player int, f string, t string)

func (*Board) PlayerBarSpace

func (b *Board) PlayerBarSpace() int

func (*Board) PlayerBearOffSpace

func (b *Board) PlayerBearOffSpace() int

func (*Board) PlayerHomeSpaces

func (b *Board) PlayerHomeSpaces() (int, int)

func (*Board) PlayerPieceAreHome

func (b *Board) PlayerPieceAreHome() bool

func (*Board) Render

func (b *Board) Render() []byte

func (*Board) ResetMoves

func (b *Board) ResetMoves()

func (*Board) ResetPreMoves

func (b *Board) ResetPreMoves()

func (*Board) ResetSelection

func (b *Board) ResetSelection()

func (*Board) SetSelection

func (b *Board) SetSelection(num int, space int)

func (*Board) SetState

func (b *Board) SetState(state string)

func (*Board) SimplifyMoves

func (b *Board) SimplifyMoves()

func (*Board) ValidMove

func (b *Board) ValidMove(f int, t int) bool

type Client

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

func NewClient(serverAddress string, username string, password string) *Client

func (*Client) CallTELNET

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 (*Client) Connect

func (c *Client) Connect() error

func (*Client) GetAllWhoInfo

func (c *Client) GetAllWhoInfo() []*WhoInfo

func (*Client) LoggedIn

func (c *Client) LoggedIn() bool

func (*Client) WatchRandomGame

func (c *Client) WatchRandomGame()

type EventBoardState

type EventBoardState struct {
    S []string
    V []int
}

type EventDraw

type EventDraw struct{}

type EventMessage

type EventMessage struct {
    Message string
}

type EventMove

type EventMove struct {
    Player int
    From   int
    To     int
}

type EventWho

type EventWho struct {
    Who []*WhoInfo
}

type 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 (*WhoInfo) String

func (w *WhoInfo) String() string