...

Package bei

Overview ▾

Constants

const (
    CommandBEI    = "bei"
    CommandList   = "list"
    CommandSet    = "set"
    CommandDouble = "double"
    CommandMove   = "move"
    CommandChoose = "choose"
)
const (
    StateHome1       = 0
    StateHome2       = 25
    StateBar1        = 26
    StateBar2        = 27
    StateRoll1       = 28
    StateRoll2       = 29
    StateRoll3       = 30
    StateTurn1       = 31
    StateTurn2       = 32
    StateCubeValue   = 33
    StateCubePlayer  = 34
    StatePoints1     = 35
    StatePoints2     = 36
    StateTotalPoints = 37
    StateCrawford    = 38
    StateJacoby      = 39
    StateMurphy      = 40
    StateBeavers     = 41
    StateVariant     = 42
    StateEntered1    = 43
    StateEntered2    = 44
)
const (
    EventTypeOkBEI      = "okbei"
    EventTypeOkList     = "oklist"
    EventTypeFailSet    = "failset"
    EventTypeOkSet      = "okset"
    EventTypeFailDouble = "faildouble"
    EventTypeOkDouble   = "okdouble"
    EventTypeFailMove   = "failmove"
    EventTypeOkMove     = "okmove"
    EventTypeFailChoose = "failchoose"
    EventTypeOkChoose   = "okchoose"
)
const CellCount = 45

func DecodeEvent

func DecodeEvent(message []byte) (interface{}, error)

func EncodeEvent

func EncodeEvent(e interface{}) ([]byte, error)

func EncodeState

func EncodeState(s *State) []int

type BeaversType

type BeaversType int
const (
    BeaversNone BeaversType = iota
    BeaversOnly
    BeaversAndRaccoons
)

type ChooseRoll

type ChooseRoll struct {
    Roll          int
    Probabilities Probabilities
}

type CubeEvaluation

type CubeEvaluation struct {
    Offer bool
    Take  bool
}

type Event

type Event struct {
    Type string
}

type EventFailChoose

type EventFailChoose struct {
    Event
    Reason string
}

type EventFailDouble

type EventFailDouble struct {
    Event
    Reason string
}

type EventFailMove

type EventFailMove struct {
    Event
    Reason string
}

type EventFailSet

type EventFailSet struct {
    Event
    Name   string
    Reason string
}

type EventOkBEI

type EventOkBEI struct {
    Event
    Version int
    ID      map[string]string
}

type EventOkChoose

type EventOkChoose struct {
    Event
    Rolls []*ChooseRoll
}

type EventOkDouble

type EventOkDouble struct {
    Event
    Cube          CubeEvaluation
    Probabilities Probabilities
}

type EventOkList

type EventOkList struct {
    Event
    List []*ListEntry
}

type EventOkMove

type EventOkMove struct {
    Event
    Moves []*Move
}

type EventOkSet

type EventOkSet struct {
    Event
    Name  string
    Value string
}

type ListEntry

type ListEntry struct {
    Name        string
    Type        SettingType
    Description string
    Default     string
    Value       string
    Min         int
    Max         int
}

type Move

type Move struct {
    Play          []*Play
    Probabilities Probabilities
}

type Play

type Play struct {
    From int
    To   int
}

type Probabilities

type Probabilities struct {
    LoseBackgammon float64
    LoseGammon     float64
    Win            float64
    WinBackgammon  float64
    WinGammon      float64
}

type SettingType

type SettingType int
const (
    SettingBoolean SettingType = iota
    SettingInteger
    SettingString
)

type State

type State struct {
    Board []int

    Roll1 int
    Roll2 int
    Roll3 int

    Turn1 int
    Turn2 int

    CubeValue  int
    CubePlayer int

    Points1     int
    Points2     int
    TotalPoints int

    Crawford bool
    Jacoby   bool
    Murphy   bool
    Beavers  BeaversType

    Variant  int
    Entered1 bool
    Entered2 bool
}

func DecodeState

func DecodeState(state []int) (*State, error)