-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat(ranking): Add RankingModes constants for GetRanking.rankingMode #79
base: master
Are you sure you want to change the base?
Conversation
This will allow downstream callers to disambiguate between the different rank request types
type rankingModes struct { | ||
// Global leaderboards | ||
Global uint8 | ||
// Ranks close to caller on global leaderboards | ||
NearbyGlobal uint8 | ||
// Friends of caller only | ||
Friends uint8 | ||
// Ranks close to caller on friends leaderboards | ||
NearbyFriends uint8 | ||
// Rank of caller only | ||
Self uint8 | ||
} | ||
|
||
// RankingModes is an enum of all the types of ranking request that can be made in the GetRanking method | ||
var RankingModes = rankingModes{ | ||
Global: 0, | ||
NearbyGlobal: 1, | ||
Friends: 2, | ||
NearbyFriends: 3, | ||
Self: 4, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this should be on the same file as the GetRanking
handling? Maybe on a different file named ranking_modes.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Dani. Having it in it's own file would make it line up with all of our other constants definition files, like those in nex-go and https://github.com/PretendoNetwork/nex-protocols-go/blob/master/match-making/gathering_flags.go
Global: 0, | ||
NearbyGlobal: 1, | ||
Friends: 2, | ||
NearbyFriends: 3, | ||
Self: 4, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cases like this where we emulate an enum where each value is sequential, we can avoid defining each value manually by using iota
(which defaults to 0). See https://github.com/PretendoNetwork/nex-go/tree/master/constants for examples
However that only applies to cases where each value is defined as its own variable, it's not applicable in this case. How you have it is fine, but wanted to give you all the options 👍
Part of PretendoNetwork/nex-protocols-common-go#34
Changes:
Add RankingModes enum for the different GetRanking request modes. This allows downstreams like nex-protocols-common-go to implement things like Friends and Nearby leaderboards.