Add GetPreMoves
This commit is contained in:
parent
c6d589455c
commit
63ce61f2bf
4
board.go
4
board.go
|
@ -623,6 +623,10 @@ func (b *Board) AddPreMove(from int, to int) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (b *Board) GetPreMoves() [][2]int {
|
||||
return b.premove
|
||||
}
|
||||
|
||||
func (b *Board) Render() []byte {
|
||||
b.Lock()
|
||||
|
||||
|
|
|
@ -519,6 +519,7 @@ func (c *Client) eventLoop() {
|
|||
var winsMatchRegexp = regexp.MustCompile(`^\w+ wins a [0-9]+ point match against .*`)
|
||||
var winsThisMatchRegexp = regexp.MustCompile(`^\w+ wins the [0-9]+ point match .*`)
|
||||
var newGameRegexp = regexp.MustCompile(`^Starting a new game with .*`)
|
||||
var joinedGameRegexp = regexp.MustCompile(`^\w+ has joined you\..*`)
|
||||
|
||||
var gameBufferRegexp = regexp.MustCompile(`^\w+ (makes|roll|rolls|rolled|move|moves) .*`)
|
||||
var pleaseMoveRegexp = regexp.MustCompile(`^Please move ([0-9]) pieces?.`)
|
||||
|
@ -616,6 +617,7 @@ func (c *Client) eventLoop() {
|
|||
} else {
|
||||
c.Board.v[StateTurn] = c.Board.v[StatePlayerColor] * -1
|
||||
}
|
||||
c.Event <- EventBoardState{S: c.Board.s, V: c.Board.v}
|
||||
} else if rollsRegexp.Match(b) {
|
||||
roll := rollsRegexp.FindSubmatch(b)
|
||||
periodIndex := bytes.IndexRune(roll[2], '.')
|
||||
|
@ -716,6 +718,9 @@ func (c *Client) eventLoop() {
|
|||
if err == nil {
|
||||
c.Board.v[StateMovablePieces] = n
|
||||
}
|
||||
} else if joinedGameRegexp.Match(b) {
|
||||
// Board state is not sent automatically when joining resumed game
|
||||
c.Out <- []byte("board")
|
||||
} else if bytes.HasPrefix(bl, []byte("you're now watching")) {
|
||||
// Board state is not sent automatically when watching
|
||||
c.Out <- []byte("board")
|
||||
|
|
Loading…
Reference in New Issue