TournamentStreamHelper icon indicating copy to clipboard operation
TournamentStreamHelper copied to clipboard

[WIP] Tracking individual games instead of just the score

Open TwilCynder opened this issue 1 year ago • 0 comments

Trying to make the scoreboard able to remember each game. This would most importantly allow us to fully report a set from TSH (#629).

It is currently in a prototype state. A lot of areas need to be changed, most importantly

  • The scoreboard widget
  • The stage strike web server
  • The code of the stage strike web app itself

I need your feedbacks and ideas on ... well, this whole mess !

The current score of the match, as well as individual games, are managed by the ScoreManager (new class) ; the Scoreboard widget owns a ScoreManager instance. When the score changes in the ScoreManager, it is reflected in the state (by OnScoreChanged) When the score is changed in the UI, instead of directly changing the state, the scoreboard widget informs the ScoreManager of the change (via OnScoreUIChanged) When an external source attemps to change the score (auto-update or stage strike app), instead of directly changing the value if the UI, we call ScoreManager.CommandScoreChange, which changes the score in the UI.
Note that CommandScoreChange calls OnScoreChanged to update the state with the new data, then updates the UI, which calls OnScoreUIChanged, which calls OnScoreChanged a second time. This is because there doesn't seem to be a safe way to make a difference between a code-induced change and an user-made change in the UI. I'm starting to hate Qt. (It isn't a problem anyway, as OnScoreChanged will check for differences and see that there isn't any -> doing nothing)

The ScoreManager can track individual games, when the information it receives allows it to ; but it may also stop tracking them ("score-only mode")

Example 1 : The score is manually changed in the UI

  • ScoreManager.OnScoreUIChanged is called with the new score
  • Calls ScoreManager.OnScoreChanged
  • Change self.score
  • If the difference with the previous score is 1 (or -1), add a game (with no info) or remove one
  • If the difference was greater, forget the games, we are now in score only mode
  • The state is updated

Example 2 : data is received from start.gg, with chars and stage :

  • ScoreManager.CommandScoreChange is called with all the data. It updates self.games with it, as well as the score; OnScoreChanged is called, updates the state
  • ScoreManager.CommandScoreChange also changes the values in the score widgets
  • This (unfortunately) triggers the valueChanged signal, which calls ScoreManager.OnScoreChanged (see TSHScoreboardWidget.py:356)
  • ScoreManager.OnScoreChanged sees that nothing changed since the last time we changed the score (as that was during the CommandScoreChange call)

REGARDING THE STAGE STRIKE WEB APP (SSWA) It should be possible to do what we want to do here without really touching the way the SSWA works, but i think this is a good occasion to try doing so. My proposal is :

  • When the Web server tries to update the score :
    • IF the "allow sswa to change score setting" is true, call ScoreManager.ReportGame directly (without using any method of TSHScoreboardWidget)
    • In that case, IF the new "keep score updated in the sswa" setting is also true, send a message to the sswa with the new score.
  • Add a "Sync SSWA", which forces the synchronization. The information sent here include the score but also who won last (useful for stage strike). If that information is not known (we are in score-only mode or the last game has no winner), the user is prompted for it before the sync message is sent.
  • Currently, from what i understand, the SSWA doesn't know the exact order of previous games (it knows who won on which stages, but not in which order). We should change that
  • Maybe when we receive an update from the SSWA and the data it holds doesn't match ours (different scores, or same score but different stages), a warning should be displayed, with the option of overwriting the ScoreManager's data OR to sync the stage strike app instead

ADDITIONAL UI : what we need to add

  • Single game reporting dialog (and the button to invoke it)
  • All-games editing dialog (and the button to invoke it)
  • "Update SSWA" button, to force the SSWA to sync with what TSH knows (with a dialog asking who won last game if the ScoreManager doesn't know)
  • Possibly, some UI somewhere informing the user that the state we received from the SSWA doesn't match what the ScoreManager has

Prototype for the All-Games Editing UI (made using my favorite professional design software, LibreOffice Draw) image

TwilCynder avatar Oct 10 '23 17:10 TwilCynder