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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ranking/get_ranking.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,25 @@ func (protocol *Protocol) handleGetRanking(packet nex.PacketInterface) {

globals.Respond(packet, rmcMessage)
}

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,
Comment on lines +111 to +115
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 👍

}
Comment on lines +96 to +116
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