▍ humdrum codex / sportsball v0.1.0
license AGPL-3.0
2.1 KB raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package model

// GameDetail is the deeper, on-demand data for a single game, fetched from
// ESPN's summary endpoint and shown in the detail view. It is league-agnostic:
// soccer populates Events (goals/cards/subs), the stick-and-ball sports
// populate BoxScore (player stat tables). Either may be empty.
type GameDetail struct {
	Events    []MatchEvent // soccer key events, chronological
	BoxScore  []TeamBox    // per-team player stat tables (away, home)
	TeamStats []TeamStat   // team-vs-team comparison stats (soccer), display order
}

// TeamStat is one away-vs-home comparison metric (possession, shots, corners…),
// rendered as a split/mirrored bar in the detail view. Values are ESPN's
// formatted display strings ("63.2", "11", "4").
type TeamStat struct {
	Label string // "Possession", "Shots", …
	Key   string // ESPN stat name, e.g. "possessionPct"
	Away  string
	Home  string
}

// MatchEvent is one notable in-match moment (goal, card, substitution…).
type MatchEvent struct {
	Clock     string   // display minute, e.g. "8'"
	Period    int      // 1=first half, 2=second…
	Type      string   // "Goal", "Yellow Card", "Substitution", …
	Text      string   // full description
	ShortText string   // concise label, e.g. "Jaidon Anthony Goal"
	Team      string   // team display name the event belongs to
	TeamID    string   // ESPN team id (preferred for side matching)
	Athletes  []string // involved players (scorer first, then assists)
	Scoring   bool     // true for goals / scoring plays
}

// TeamBox is one team's box score: a set of stat groups (batting/pitching,
// passing/rushing, a single group for basketball, …).
type TeamBox struct {
	Abbr   string
	Name   string
	Groups []StatGroup
}

// StatGroup is one labeled table of player rows (e.g. "passing").
type StatGroup struct {
	Name   string   // group label, e.g. "batting", "passing"
	Labels []string // column headers, parallel to each PlayerRow.Stats
	Rows   []PlayerRow
}

// PlayerRow is one athlete's stat line within a group.
type PlayerRow struct {
	Athlete string
	Stats   []string // parallel to the group's Labels
}