2024-07-04 04:52:40 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "scm.dairydemon.net/filifa/mlblive/internal/statsapi"
|
|
|
|
|
|
|
|
type Game struct {
|
|
|
|
CurrPlayDesc string
|
|
|
|
HomeScore uint
|
|
|
|
AwayScore uint
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Game) Update(feed *statsapi.FeedResponse) {
|
|
|
|
homeScore, _ := (*feed)["liveData"].(map[string]any)["linescore"].(map[string]any)["teams"].(map[string]any)["home"].(map[string]any)["runs"].(float64)
|
|
|
|
awayScore, _ := (*feed)["liveData"].(map[string]any)["linescore"].(map[string]any)["teams"].(map[string]any)["away"].(map[string]any)["runs"].(float64)
|
2024-07-11 04:47:51 +00:00
|
|
|
// FIXME: currentPlay/result doesn't always have description
|
2024-07-04 04:52:40 +00:00
|
|
|
desc, _ := (*feed)["liveData"].(map[string]any)["plays"].(map[string]any)["currentPlay"].(map[string]any)["result"].(map[string]any)["description"].(string)
|
|
|
|
|
|
|
|
g.HomeScore = uint(homeScore)
|
|
|
|
g.AwayScore = uint(awayScore)
|
|
|
|
g.CurrPlayDesc = desc
|
|
|
|
}
|