diff options
Diffstat (limited to 'rankings/models.go')
| -rw-r--r-- | rankings/models.go | 51 |
1 files changed, 51 insertions, 0 deletions
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 @@ | |||
| 1 | package main | ||
| 2 | |||
| 3 | type Record struct { | ||
| 4 | MapID int `json:"id"` | ||
| 5 | MapName string `json:"name"` | ||
| 6 | MapMode int `json:"mode"` | ||
| 7 | MapWR int `json:"wr"` | ||
| 8 | MapLimit *int `json:"limit"` | ||
| 9 | } | ||
| 10 | |||
| 11 | type Leaderboard struct { | ||
| 12 | Entries LeaderboardEntries `xml:"entries"` | ||
| 13 | } | ||
| 14 | |||
| 15 | func (l *Leaderboard) needsAnotherPage(record *Record) bool { | ||
| 16 | if l.Entries.Entry[len(l.Entries.Entry)-1].Score == record.MapWR { | ||
| 17 | return true | ||
| 18 | } else if record.MapLimit != nil && l.Entries.Entry[len(l.Entries.Entry)-1].Score <= *record.MapLimit { | ||
| 19 | return true | ||
| 20 | } | ||
| 21 | return false | ||
| 22 | } | ||
| 23 | |||
| 24 | type LeaderboardEntries struct { | ||
| 25 | Entry []LeaderboardEntry `xml:"entry"` | ||
| 26 | } | ||
| 27 | |||
| 28 | type LeaderboardEntry struct { | ||
| 29 | SteamID string `xml:"steamid"` | ||
| 30 | Score int `xml:"score"` | ||
| 31 | } | ||
| 32 | |||
| 33 | type Player struct { | ||
| 34 | Username string `json:"user_name"` | ||
| 35 | AvatarLink string `json:"avatar_link"` | ||
| 36 | SteamID string `json:"steam_id"` | ||
| 37 | Entries []PlayerEntry `json:"-"` | ||
| 38 | SpScoreCount int `json:"sp_score"` | ||
| 39 | MpScoreCount int `json:"mp_score"` | ||
| 40 | OverallScoreCount int `json:"overall_score"` | ||
| 41 | SpRank int `json:"sp_rank"` | ||
| 42 | MpRank int `json:"mp_rank"` | ||
| 43 | OverallRank int `json:"overall_rank"` | ||
| 44 | SpIterations int `json:"-"` | ||
| 45 | MpIterations int `json:"-"` | ||
| 46 | } | ||
| 47 | |||
| 48 | type PlayerEntry struct { | ||
| 49 | MapID int | ||
| 50 | MapScore int | ||
| 51 | } | ||