Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add playerCentered option to loadLeaderboards. #165

Merged

Conversation

theLee3
Copy link
Collaborator

@theLee3 theLee3 commented Aug 8, 2024

When retrieving leaderboards via the loadLeaderboards method, devs may wish to center the results around the player's ranking. To provide this functionality, we can add a playerCentered parameter to the method call.

GPG provides a method loadPlayerCenteredScores so we simply call the correct method based on the value of playerCentered.

GK does not provide a specific method for this, but we can find the player's rank via loadEntries(for: currentPlayer) and use the resulting localPlayer.rank to calculate the NSRange to pass to the subsequent loadEntries call.

Both implementations return the top scores if the user does not have an entry on the leaderboard.

@theLee3
Copy link
Collaborator Author

theLee3 commented Aug 8, 2024

Will need to add to changelog when merged.

@Abedalkareem
Copy link
Owner

Hi @theLee3 !

Nice addition!
Can you fix the conflicts?

Thanks!

@theLee3 theLee3 force-pushed the player_centered_leaderboards branch from fd6f920 to d5d3b76 Compare August 12, 2024 16:45
@theLee3
Copy link
Collaborator Author

theLee3 commented Aug 12, 2024

Done.

@Abedalkareem Abedalkareem merged commit f59c276 into Abedalkareem:develop Aug 14, 2024
1 check failed
@theLee3 theLee3 deleted the player_centered_leaderboards branch August 14, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants