Add setting for flipping board
This commit is contained in:
parent
1146b1c5c3
commit
fb58a25c67
7 changed files with 22 additions and 8 deletions
|
@ -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)
|
||||
|
||||
|
|
1
event.go
1
event.go
|
@ -115,6 +115,7 @@ type EventSettings struct {
|
|||
Highlight bool
|
||||
Pips bool
|
||||
Moves bool
|
||||
Flip bool
|
||||
}
|
||||
|
||||
type EventReplay struct {
|
||||
|
|
2
go.mod
2
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
|
||||
)
|
||||
|
|
4
go.sum
4
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=
|
||||
|
|
|
@ -8,4 +8,5 @@ type account struct {
|
|||
highlight bool
|
||||
pips bool
|
||||
moves bool
|
||||
flip bool
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 <name> <value>")
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue