Skip to content

Commit

Permalink
Flatten game
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbuddy committed Mar 21, 2024
1 parent 16a736e commit fff120a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,12 @@ func (s *Server) reprocessHistory(req *ReprocessRequest) (*ReprocessResponse, er
errs <- fmt.Errorf("error loading game: %w", err)
return
}
if _, err := ctx.RunScript(`if (game.default) {
game = game.default
}`, "game.js"); err != nil {
errs <- fmt.Errorf("error flattening game structure: %w", err)
return
}
script := fmt.Sprintf("JSON.stringify(game.reprocessHistory(%s, %s))", string(setup), string(moves))
val, err := ctx.RunScript(script, "reprocessHistory.js")
if err != nil {
Expand Down

0 comments on commit fff120a

Please sign in to comment.