Follow the leader with help from a server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
|
- // NGnius 2020-01-30
-
- package main
-
- import (
- "strconv"
- "time"
- )
-
- // Board a leaderboard
- type BoardJSON struct {
- ID int64
- Entries []EntryJSON
- Name string
- }
-
- // Entry an entry in a leaderboard
- type EntryJSON struct {
- ID int64
- Rank int64
- Score int64
- PlayerName string
- PlayerURL string
- }
-
- // Player a player
- type PlayerJSON struct {
- ID int64
- Name string
- Entries []EntryJSON
- }
-
- // URL get the player's URL
- func (p *PlayerJSON) URL() string {
- return "/player/" + strconv.Itoa(int(p.ID))
- }
-
- // Result a query result
- type Result struct {
- Items []interface{}
- Elapsed int64
- Count int
- Query string
- URL string
- Start time.Time
- }
-
- // NewResult build a query struct
- func NewResult(q string, url string) (r Result) {
- r.Start = time.Now()
- r.Query = q
- r.URL = url
- return
- }
-
- // Complete finish the result
- func (r *Result) Complete() {
- r.Count = len(r.Items)
- r.Elapsed = time.Since(r.Start).Milliseconds()
- }
|