PretendoNetwork / nex-protocols-common-go

Reusable implementations of NEX methods found in many servers
GNU Affero General Public License v3.0
19 stars 8 forks source link

feat!(ranking): Add new methods for the different ranking modes on GetRanking #34

Open ashquarky opened 5 months ago

ashquarky commented 5 months ago

There's 5 different types of GetRanking call, asking for:

These are pretty fundamentally different requests that would need different db queries, etc. at the implementation level. Notably all but the first need knowledge of the PID of the user making the request (to get their rank and their friends).

Changes:

Add new methods to the protocol for each of these use cases.

Submitting as a draft because I know if rankingMode.Value == 0 { is the wrong way to do it, but I couldn't find any other protocol with constants like that for me to reference against. If someone count point out where I should define constants for this sort of thing I'll happily clean up the magic numbers.

There's a highly WIP implementation of this API here: https://github.com/ashquarky/puyo-wiiu/blob/ranking/datastore/puyo_ranking.go

Note the dramatically different database requests needed for each mode.

DaniElectra commented 5 months ago

We define the relevant constants for protocols inside nex-protocols-go. See this example: https://github.com/PretendoNetwork/nex-protocols-go/blob/master/nintendo-notifications/notification_types.go

We could also replace that big if statement with a switch case