Add setting for advanced checker movement

This commit is contained in:
Trevor Slocum 2024-01-11 11:34:02 -08:00
parent 3eb433e573
commit 262ad93e51
4 changed files with 9 additions and 4 deletions

View file

@ -118,6 +118,7 @@ type EventSettings struct {
Pips bool
Moves bool
Flip bool
Advanced bool
}
type EventReplay struct {

View file

@ -10,4 +10,5 @@ type account struct {
pips bool
moves bool
flip bool
advanced bool
}

View file

@ -51,7 +51,8 @@ CREATE TABLE account (
highlight smallint NOT NULL DEFAULT 1,
pips smallint NOT NULL DEFAULT 1,
moves smallint NOT NULL DEFAULT 0,
flip smallint NOT NULL DEFAULT 0
flip smallint NOT NULL DEFAULT 0,
advanced smallint NOT NULL DEFAULT 0
);
CREATE TABLE game (
id serial PRIMARY KEY,
@ -342,8 +343,8 @@ func loginAccount(passwordSalt string, username []byte, password []byte) (*accou
defer tx.Commit(context.Background())
a := &account{}
var autoplay, highlight, pips, moves, flip int
err = tx.QueryRow(context.Background(), "SELECT id, email, username, password, autoplay, 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, &autoplay, &highlight, &pips, &moves, &flip)
var autoplay, highlight, pips, moves, flip, advanced int
err = tx.QueryRow(context.Background(), "SELECT id, email, username, password, autoplay, highlight, pips, moves, flip, advanced 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, &autoplay, &highlight, &pips, &moves, &flip, &advanced)
if err != nil {
return nil, nil
} else if len(a.password) == 0 {
@ -354,6 +355,7 @@ func loginAccount(passwordSalt string, username []byte, password []byte) (*accou
a.pips = pips == 1
a.moves = moves == 1
a.flip = flip == 1
a.advanced = advanced == 1
match, err := argon2id.ComparePasswordAndHash(string(password)+passwordSalt, string(a.password))
if err != nil {

View file

@ -174,6 +174,7 @@ COMMANDS:
Pips: a.pips,
Moves: a.moves,
Flip: a.flip,
Advanced: a.advanced,
})
} else {
cmd.client.account = 0
@ -1093,7 +1094,7 @@ COMMANDS:
}
name := string(bytes.ToLower(params[0]))
settings := []string{"autoplay", "highlight", "pips", "moves", "flip"}
settings := []string{"autoplay", "highlight", "pips", "moves", "flip", "advanced"}
var found bool
for i := range settings {
if name == settings[i] {