|
|
|
@ -523,7 +523,6 @@ func (c *Client) eventLoop() {
@@ -523,7 +523,6 @@ func (c *Client) eventLoop() {
|
|
|
|
|
var movesRegexp = regexp.MustCompile(`^(\w+) moves (.*)`) |
|
|
|
|
var rollsRegexp = regexp.MustCompile(`^(\w+) rolls? (.*)`) |
|
|
|
|
var logInOutRegexp = regexp.MustCompile(`^\w+ logs [In|Out]\.`) |
|
|
|
|
var dropsConnection = regexp.MustCompile(`^\w+ drops connection\.`) |
|
|
|
|
var startMatchRegexp = regexp.MustCompile(`^\w+ and \w+ start a .*`) |
|
|
|
|
var winsMatchRegexp = regexp.MustCompile(`^\w+ wins a [0-9]+ point match against .*`) |
|
|
|
|
var winsThisMatchRegexp = regexp.MustCompile(`^\w+ wins the [0-9]+ point match .*`) |
|
|
|
@ -533,7 +532,8 @@ func (c *Client) eventLoop() {
@@ -533,7 +532,8 @@ func (c *Client) eventLoop() {
|
|
|
|
|
|
|
|
|
|
var gameBufferRegexp = regexp.MustCompile(`^\w+ (makes|roll|rolls|rolled|move|moves) .*`) |
|
|
|
|
var pleaseMoveRegexp = regexp.MustCompile(`^Please move ([0-9]) pieces?.`) |
|
|
|
|
var cantMoveRegexp = regexp.MustCompile(`^(\w+) can't move.`) |
|
|
|
|
var invalidMoveRegexp = regexp.MustCompile(`^\*\* You can't move .*`) |
|
|
|
|
var cantMoveRegexp = regexp.MustCompile(`^(\w+) can't move\.`) |
|
|
|
|
var doublesRegexp = regexp.MustCompile(`^\w+ doubles.`) |
|
|
|
|
var acceptDoubleRegexp = regexp.MustCompile(`^\w+ accepts the double.`) |
|
|
|
|
|
|
|
|
@ -592,7 +592,7 @@ func (c *Client) eventLoop() {
@@ -592,7 +592,7 @@ func (c *Client) eventLoop() {
|
|
|
|
|
continue |
|
|
|
|
} else if bytes.HasPrefix(b, TypeMOTD) { |
|
|
|
|
for _, line := range bytes.Split(c.motd, []byte("\n")) { |
|
|
|
|
l(string(line)) |
|
|
|
|
l(strings.ReplaceAll(string(line), "|", " ")) |
|
|
|
|
} |
|
|
|
|
if !setBoardStyle { |
|
|
|
|
c.Out <- []byte("set boardstyle 3") |
|
|
|
@ -617,9 +617,6 @@ func (c *Client) eventLoop() {
@@ -617,9 +617,6 @@ func (c *Client) eventLoop() {
|
|
|
|
|
} else if bytes.HasPrefix(b, TypeLogin) || bytes.HasPrefix(b, TypeLogout) { |
|
|
|
|
b = b[2:] |
|
|
|
|
b = b[bytes.IndexByte(b, ' ')+1:] |
|
|
|
|
l(string(b)) |
|
|
|
|
// TODO enable showing log In and Out messages
|
|
|
|
|
// TODO remove from who
|
|
|
|
|
continue |
|
|
|
|
} else if bytes.HasPrefix(b, TypeMsg) { |
|
|
|
|
lf("Received message: %s", b[3:]) |
|
|
|
@ -717,6 +714,9 @@ func (c *Client) eventLoop() {
@@ -717,6 +714,9 @@ func (c *Client) eventLoop() {
|
|
|
|
|
if strings.TrimSpace(string(b)) == "It's your turn to roll or double." || strings.TrimSpace(string(b)) == "It's your turn. Please roll or double" { |
|
|
|
|
c.Out <- []byte("roll") // TODO Delay and allow configuring
|
|
|
|
|
} |
|
|
|
|
} else if invalidMoveRegexp.Match(b) { |
|
|
|
|
c.Board.ResetPreMoves() |
|
|
|
|
c.Board.Draw() |
|
|
|
|
} else if cantMoveRegexp.Match(b) { |
|
|
|
|
match := cantMoveRegexp.FindSubmatch(b) |
|
|
|
|
|
|
|
|
@ -751,8 +751,6 @@ func (c *Client) eventLoop() {
@@ -751,8 +751,6 @@ func (c *Client) eventLoop() {
|
|
|
|
|
}() |
|
|
|
|
} else if logInOutRegexp.Match(b) { |
|
|
|
|
continue |
|
|
|
|
} else if dropsConnection.Match(b) { |
|
|
|
|
continue |
|
|
|
|
} else if startMatchRegexp.Match(b) { |
|
|
|
|
continue |
|
|
|
|
} else if winsThisMatchRegexp.Match(b) { |
|
|
|
|