Skip to content

Commit

Permalink
Fix appeal detection
Browse files Browse the repository at this point in the history
  • Loading branch information
klydra committed Feb 22, 2023
1 parent d6cf586 commit fa5529e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,11 @@ func main() {
return err
}

globals, err := globalsFromGame(game)
if err != nil {
return err
}

// Retrieve target player
target, err := getPlayerRecordByName(app, c.Request().Header.Get("player"))
if err != nil {
Expand All @@ -1415,6 +1420,16 @@ func main() {
return err
}

// Check if target player had the previous turn
next, err := nextPlayer(c.Request().Header.Get("player"), players, globals)
if err != nil {
return err
}

if globals.Live != players[next].Name {
return apis.NewBadRequestError("Game has already advanced multiple turns.", err)
}

// Check if appeal is valid
if players[targetIndex].Called {
return apis.NewBadRequestError("Player has already called.", err)
Expand Down

0 comments on commit fa5529e

Please sign in to comment.