thecommons-urbit / chess

Distribution repo for Urbit Chess app
Other
26 stars 8 forks source link

Pass practice game info to the frontend #157

Closed ashelkovnykov closed 6 months ago

ashelkovnykov commented 1 year ago

After #154, when a game ends it's still shown in the archive until a refresh. There is code to fix this bug in chessStore, but it relies on getting info about whether a game is a practice match or not from the backend to the front end. How to do this elegantly is still unclear. Proposed solutions:

  1. Move isPractice into chess-game instead of active-game-state
  2. Add an event that gets sent to the frontend that specifies a game as practice after it's created
  3. A custom mark for sending game info to the frontend: [chess-game practice=?]

As part of #154, @rovmug-ticfyn implemented solution 2, but it was quite ugly (not the code; the things that had to be done to get it to work). Solution 1, though simple, is just incorrect, as chess-game should not know any context about what kind of game it is. Solution 3 seems like it has the most potential, as it's almost as simple as solution 1, but hides the ugliness of the solution inside a separate mark.

NOTE: Just recording the info about whether a game is a practice match or not from the challenge will not work. Each refresh to the browser window kills the old session and starts a new one, meaning that the frontend can now only get info about active games from the %chess backend, and therefore it needs some way to do this.