Write docs!
This commit is contained in:
parent
c460bb7bf5
commit
bcc598ebd5
37 changed files with 478 additions and 188 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// statLine is a line of statistics for the file stats.json exposed to players.
|
||||
type statLine struct {
|
||||
Tip string `json:"tip"`
|
||||
Total int `json:"total"`
|
||||
|
|
@ -12,11 +13,13 @@ type statLine struct {
|
|||
Tries int `json:"tries"`
|
||||
}
|
||||
|
||||
// teamStats represents the structure of stats.json.
|
||||
type teamStats struct {
|
||||
Levels []statLine `json:"levels"`
|
||||
Themes map[int64]statLine `json:"themes"`
|
||||
}
|
||||
|
||||
// GetLevel
|
||||
func (s *teamStats) GetLevel(level int) *statLine {
|
||||
level -= 1
|
||||
|
||||
|
|
@ -33,10 +36,12 @@ func (s *teamStats) GetLevel(level int) *statLine {
|
|||
return &s.Levels[level]
|
||||
}
|
||||
|
||||
// GetStats generates statistics for the Team.
|
||||
func (t Team) GetStats() (interface{}, error) {
|
||||
return GetTeamsStats(&t)
|
||||
}
|
||||
|
||||
// GetTeamsStats returns statistics limited to the given Team.
|
||||
func GetTeamsStats(t *Team) (interface{}, error) {
|
||||
stat := teamStats{
|
||||
[]statLine{},
|
||||
|
|
@ -66,12 +71,12 @@ func GetTeamsStats(t *Team) (interface{}, error) {
|
|||
sLvl.Total += 1
|
||||
|
||||
if t != nil {
|
||||
if b, _, _ := t.HasSolved(exercice); b {
|
||||
if b, _ := t.HasSolved(exercice); b {
|
||||
solved += 1
|
||||
sLvl.Solved += 1
|
||||
}
|
||||
} else {
|
||||
if n, _ := IsSolved(exercice); n > 0 {
|
||||
if n, _ := exercice.IsSolved(); n > 0 {
|
||||
solved += 1
|
||||
sLvl.Solved += 1
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue