Follow the leader with help from a server
No puede seleccionar más de 25 temas
Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Este repositorio está archivado. Puede ver los archivos y clonarlo, pero no puede subir cambios o reportar incidencias ni pedir 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()
- }
|