From df6f6cb5ff8957be8f01d58d60857da2c094a3d9 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Thu, 12 Sep 2024 00:25:15 +0300 Subject: refactor: unofficial rankings implementation --- rankings/models.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 rankings/models.go (limited to 'rankings/models.go') diff --git a/rankings/models.go b/rankings/models.go new file mode 100644 index 0000000..1b349b0 --- /dev/null +++ b/rankings/models.go @@ -0,0 +1,51 @@ +package main + +type Record struct { + MapID int `json:"id"` + MapName string `json:"name"` + MapMode int `json:"mode"` + MapWR int `json:"wr"` + MapLimit *int `json:"limit"` +} + +type Leaderboard struct { + Entries LeaderboardEntries `xml:"entries"` +} + +func (l *Leaderboard) needsAnotherPage(record *Record) bool { + if l.Entries.Entry[len(l.Entries.Entry)-1].Score == record.MapWR { + return true + } else if record.MapLimit != nil && l.Entries.Entry[len(l.Entries.Entry)-1].Score <= *record.MapLimit { + return true + } + return false +} + +type LeaderboardEntries struct { + Entry []LeaderboardEntry `xml:"entry"` +} + +type LeaderboardEntry struct { + SteamID string `xml:"steamid"` + Score int `xml:"score"` +} + +type Player struct { + Username string `json:"user_name"` + AvatarLink string `json:"avatar_link"` + SteamID string `json:"steam_id"` + Entries []PlayerEntry `json:"-"` + SpScoreCount int `json:"sp_score"` + MpScoreCount int `json:"mp_score"` + OverallScoreCount int `json:"overall_score"` + SpRank int `json:"sp_rank"` + MpRank int `json:"mp_rank"` + OverallRank int `json:"overall_rank"` + SpIterations int `json:"-"` + MpIterations int `json:"-"` +} + +type PlayerEntry struct { + MapID int + MapScore int +} -- cgit v1.2.3