// Package model holds league-agnostic domain types used across the UI. // ESPN-specific JSON is decoded in the espn package and mapped into these. package model import "time" // State is the coarse lifecycle of a game, normalized from ESPN's // status.type.state ("pre" | "in" | "post"). type State int const ( StatePre State = iota // scheduled, not started StateLive // in progress StateFinal // completed ) func (s State) String() string { switch s { case StateLive: return "LIVE" case StateFinal: return "FINAL" default: return "SCHED" } } // Team is one side of a competition. type Team struct { ID string // stable ESPN team id, used to key favorites Abbr string // e.g. "PHI" Name string // short display name, e.g. "Phillies" FullName string // e.g. "Philadelphia Phillies" Color string // primary hex color w/o leading '#', from ESPN AltColor string Score int Record string // e.g. "40-30" Winner bool } // Game is a single matchup, normalized across all leagues. type Game struct { ID string League LeagueID Start time.Time State State Home Team Away Team Detail string // status.type.detail, e.g. "Top 5th", "Final/10", "6:40 PM EDT" Clock string // displayClock when live Period int // inning / quarter / half Venue string Headline string // optional recap/odds blurb // Situation is the live play state, currently baseball-only (count, outs, // bases, pitcher/batter). Nil when absent (not live, or sport without it). Situation *Situation } // Situation is the live in-game state for baseball: the count, outs, occupied // bases, and who's at the plate / on the mound. Populated from the scoreboard // endpoint's competition situation while a game is live. type Situation struct { Balls, Strikes, Outs int OnFirst, OnSecond, OnThird bool Pitcher, Batter string // display names PitcherLine, BatterLine string // ESPN summary lines ("5.1 IP, 2 ER…", "1-3") LastPlay string } // Started reports whether play has begun (live or final). func (g Game) Started() bool { return g.State != StatePre }