From c231f199596f7b9836b485502f3b3eef5547a323 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Mon, 19 Aug 2024 19:56:51 -0700 Subject: [PATCH] Fix bearing off checkers in the appropriate order --- game.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- pkg/server/client.go | 38 ++++++++++++++++++++++++++++++++++++ pkg/server/server_command.go | 8 ++++---- 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/game.go b/game.go index 2253085..c85ee8b 100644 --- a/game.go +++ b/game.go @@ -587,7 +587,7 @@ func (g *Game) LegalMoves(local bool) [][]int8 { break } } - if !found { + if !found && b.HaveRoll(available[i][j][0], available[i][j][1], g.Turn) { moves = append(moves, []int8{available[i][j][0], available[i][j][1]}) } } diff --git a/go.mod b/go.mod index eabfd6f..4e45a7e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( code.rocket9labs.com/tslocum/gotext v0.0.0-20240728181248-46f419ff143b - code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999 + code.rocket9labs.com/tslocum/tabula v0.0.0-20240820025521-91065b63f1be github.com/alexedwards/argon2id v1.0.0 github.com/coder/websocket v1.8.12 github.com/gorilla/mux v1.8.1 diff --git a/go.sum b/go.sum index f18cadf..c7abe63 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b h1:Y0a14Kf/h code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc= code.rocket9labs.com/tslocum/gotext v0.0.0-20240728181248-46f419ff143b h1:KSdR7VPoftY5Bt+osGRBbtHlCWxhe1QbOuf58CG7ieI= code.rocket9labs.com/tslocum/gotext v0.0.0-20240728181248-46f419ff143b/go.mod h1:ZkYZ/IF/ebzhUL2bNp4ALROsuH9iCztUWvUJBWsHXRU= -code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999 h1:PwfoDBtxVT3TwL2KpoijPKi6NQsGu6cXhPVoQeqKJWM= -code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999/go.mod h1:WEJXESKXqrMFLAArikQ79lpRibNeeE1C0VruxXYMF5M= +code.rocket9labs.com/tslocum/tabula v0.0.0-20240820025521-91065b63f1be h1:awgpl3vS+d7vciw7X5z+joGSPZHB1OOTpkPKW3mPGDs= +code.rocket9labs.com/tslocum/tabula v0.0.0-20240820025521-91065b63f1be/go.mod h1:WEJXESKXqrMFLAArikQ79lpRibNeeE1C0VruxXYMF5M= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= diff --git a/pkg/server/client.go b/pkg/server/client.go index 75b3b15..339e288 100644 --- a/pkg/server/client.go +++ b/pkg/server/client.go @@ -238,6 +238,7 @@ func (c *serverClient) Terminate(reason string) { func logClientRead(msg []byte) { msgLower := bytes.ToLower(msg) loginJSON := bytes.HasPrefix(msgLower, []byte("loginjson ")) || bytes.HasPrefix(msgLower, []byte("lj ")) + registerJSON := bytes.HasPrefix(msgLower, []byte("registerjson ")) || bytes.HasPrefix(msgLower, []byte("rj ")) if bytes.HasPrefix(msgLower, []byte("login ")) || bytes.HasPrefix(msgLower, []byte("l ")) || loginJSON { split := bytes.Split(msg, []byte(" ")) var clientName []byte @@ -267,6 +268,43 @@ func logClientRead(msg []byte) { clientName = []byte("unspecified") } log.Printf("<- %s %s %s %s", split[0], clientName, username, password) + } else if bytes.HasPrefix(msgLower, []byte("register ")) || registerJSON { + split := bytes.Split(msg, []byte(" ")) + var clientName []byte + var email []byte + var username []byte + var password []byte + l := len(split) + if l > 1 { + if registerJSON { + clientName = split[1] + } else { + email = []byte("*******") + } + if l > 2 { + if registerJSON { + email = []byte("*******") + } else { + username = split[2] + } + if l > 3 { + if registerJSON { + username = split[3] + } else { + password = []byte("*******") + } + if l > 4 { + if registerJSON { + password = []byte("*******") + } + } + } + } + } + if len(clientName) == 0 { + clientName = []byte("unspecified") + } + log.Printf("<- %s %s %s %s %s", split[0], clientName, email, username, password) } else if !bytes.HasPrefix(msgLower, []byte("list")) && !bytes.HasPrefix(msgLower, []byte("ls")) && !bytes.HasPrefix(msgLower, []byte("pong")) { log.Printf("<- %s", msg) } diff --git a/pkg/server/server_command.go b/pkg/server/server_command.go index 4f7fe65..aa7bdb7 100644 --- a/pkg/server/server_command.go +++ b/pkg/server/server_command.go @@ -1358,14 +1358,14 @@ COMMANDS: continue } - clientGame.Turn = 2 - clientGame.Roll1 = 4 - clientGame.Roll2 = 6 + clientGame.Turn = 1 + clientGame.Roll1 = 3 + clientGame.Roll2 = 3 clientGame.Roll3 = 0 clientGame.Variant = 0 clientGame.Player1.Entered = true clientGame.Player2.Entered = true - clientGame.Board = []int8{0, 0, 2, 2, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 1, -3, 1, 0, -3, -6, -2, 0, 0, 0} + clientGame.Board = []int8{0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, -3, 0, 0, -3, -6, -2, 0, 0, 0} log.Println(clientGame.Board[0:28])