diff --git a/REPLAY.md b/REPLAY.md index febb75a..4ac9ae1 100644 --- a/REPLAY.md +++ b/REPLAY.md @@ -1,6 +1,7 @@ # Specification of bgammon.org replay file -Replays are stored as .match files with lines separated by newline characters only (no carriage-return characters). +Replays are stored as .match files with lines separated by newline characters only +(no carriage-return characters). Replay files are always UTF-8 encoded. ## Match format (.match) diff --git a/event.go b/event.go index 702664b..1d587d6 100644 --- a/event.go +++ b/event.go @@ -115,6 +115,7 @@ type EventSettings struct { Highlight bool Pips bool Moves bool + Flip bool } type EventReplay struct { diff --git a/go.mod b/go.mod index 747fb1e..bf6e4a9 100644 --- a/go.mod +++ b/go.mod @@ -37,6 +37,6 @@ require ( github.com/vanng822/go-premailer v1.20.2 // indirect golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.19.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 4d0494d..8ddeb76 100644 --- a/go.sum +++ b/go.sum @@ -139,8 +139,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= diff --git a/pkg/server/account.go b/pkg/server/account.go index bb9daa2..05cff6d 100644 --- a/pkg/server/account.go +++ b/pkg/server/account.go @@ -8,4 +8,5 @@ type account struct { highlight bool pips bool moves bool + flip bool } diff --git a/pkg/server/database.go b/pkg/server/database.go index cd55471..34771b2 100644 --- a/pkg/server/database.go +++ b/pkg/server/database.go @@ -45,7 +45,8 @@ CREATE TABLE account ( rated_acey_multi integer NOT NULL DEFAULT 150000, highlight smallint NOT NULL DEFAULT 1, pips smallint NOT NULL DEFAULT 1, - moves smallint NOT NULL DEFAULT 0 + moves smallint NOT NULL DEFAULT 0, + flip smallint NOT NULL DEFAULT 0 ); CREATE TABLE game ( id serial PRIMARY KEY, @@ -336,8 +337,8 @@ func loginAccount(passwordSalt string, username []byte, password []byte) (*accou defer tx.Commit(context.Background()) a := &account{} - var highlight, pips, moves int - err = tx.QueryRow(context.Background(), "SELECT id, email, username, password, highlight, pips, moves FROM account WHERE username = $1 OR email = $2", bytes.ToLower(bytes.TrimSpace(username)), bytes.ToLower(bytes.TrimSpace(username))).Scan(&a.id, &a.email, &a.username, &a.password, &highlight, &pips, &moves) + var highlight, pips, moves, flip int + err = tx.QueryRow(context.Background(), "SELECT id, email, username, password, highlight, pips, moves, flip FROM account WHERE username = $1 OR email = $2", bytes.ToLower(bytes.TrimSpace(username)), bytes.ToLower(bytes.TrimSpace(username))).Scan(&a.id, &a.email, &a.username, &a.password, &highlight, &pips, &moves, &flip) if err != nil { return nil, nil } else if len(a.password) == 0 { @@ -346,6 +347,7 @@ func loginAccount(passwordSalt string, username []byte, password []byte) (*accou a.highlight = highlight == 1 a.pips = pips == 1 a.moves = moves == 1 + a.flip = flip == 1 match, err := argon2id.ComparePasswordAndHash(string(password)+passwordSalt, string(a.password)) if err != nil { diff --git a/pkg/server/server.go b/pkg/server/server.go index 2243e72..ed0b530 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -842,6 +842,7 @@ COMMANDS: Highlight: a.highlight, Pips: a.pips, Moves: a.moves, + Flip: a.flip, }) } else { cmd.client.account = 0 @@ -1896,7 +1897,15 @@ COMMANDS: } name := string(bytes.ToLower(params[0])) - if name != "highlight" && name != "pips" && name != "moves" { + settings := []string{"highlight", "pips", "moves", "flip"} + var found bool + for i := range settings { + if name == settings[i] { + found = true + break + } + } + if !found { cmd.client.sendNotice("Please specify the setting name and value as follows: set ") continue }