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

feat(ranking): Add RankingModes constants for GetRanking.rankingMode #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ashquarky
Copy link
Member

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.

This will allow downstream callers to disambiguate between the different rank request types
Comment on lines +96 to +116
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,
}
Copy link
Member

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?

Copy link
Member

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

Comment on lines +111 to +115
Global: 0,
NearbyGlobal: 1,
Friends: 2,
NearbyFriends: 3,
Self: 4,
Copy link
Member

@jonbarrow jonbarrow Jun 30, 2024

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 👍

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.

3 participants