PlaydateSquad / pdScoreboards

MIT License
2 stars 0 forks source link

Scoreboards enabled after release are not used by the library if local scoreboards exist #1

Open rubybrowncoat opened 10 months ago

rubybrowncoat commented 10 months ago

I think this check keeps the game locked into local scoreboards even once they eventually exist (for the catalog game): https://github.com/GammaGames/pdScoreboards/blob/83401d38f65bc8b9070f9d58fb3fd992006dd5ec/pdScoreboards.lua#L172-L176

GammaGames commented 9 months ago

🤔 Thank you for reporting this, I'll take a look when I get the chance! I remember some discussion around tweaking how the official scoreboards worked a bit ago so it might be related to that.

rubybrowncoat commented 9 months ago

The issue here seems to be specifically with that check, and not with the official APIs, in the sense that: scoreboards is read from the datastore scoreboards_file so if at any point in time the initialize function failed the official getScoreboards call for whatever reason and _init_scoreboards is called, the scoreboards_file gets created so that first component of the check is ~= nil, and since _init_scoreboards always sets scoreboards.not_authorized as true and _saves it that second component, if the scoreboards_file exists, is also always true.

This means that if _init_scoreboards is ever called then on any following initialize it will always be called, and from that point local scoreboards are active regardless.

GammaGames commented 9 months ago

Good catch!! I'll try to get a fix in within the next few days

GammaGames commented 9 months ago

I opted to remove the attempt at caching authorization: https://github.com/GammaGames/pdScoreboards/pull/2

rubybrowncoat commented 9 months ago

That's pretty much what I did in my copy to bypass the issue. 👍

GammaGames commented 9 months ago

Thanks for the feedback, I merged it. And congrats on the catalog launch! 🎉

ebeneliason commented 1 month ago

I realize this is an old thread, but since it's still open despite the fix and my inquiry is related I'll revive it. If these are better suited as separate issues let me know.

  1. I think a lot of the value in having this convenient wrapper would be specifically to enable seamless migration to global scoreboards if/when they become available. That would require the locally cached high scores to get communicated to Panic's scoreboard servers. Does this happen magically already because the format used by this lib matches the scoreboard APIs own offline caching format? (does it?) Or could/should something be added to the API to report at least the highest local score to the global boards when they successfully load the first time? Actually — does this library interfere with that offline caching of the official APIs?

  2. For some games there could be value in exposing both local and global leaderboards. As far as I can tell, the official scoreboard APIs don't provide any way to fetch all of a user's own high scores — just their highest on any given board (unless they happen to hold multiple top ten scores). Would you consider extending this library so as to provide local high score functionality in addition to the global functionality (if available)? I suppose you'd need an optional flag to getScores (or a getLocalScores function), and probably a way to check whether global high scores are available or not.

Thanks!