mlblive/game.go

33 lines
664 B
Go
Raw Normal View History

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
}
2024-07-13 21:37:04 +00:00
func (g *Game) Update(feed *statsapi.Feed) error {
homeScore := feed.LiveData.Linescore.Teams.Home.Runs
awayScore := feed.LiveData.Linescore.Teams.Away.Runs
2024-07-11 04:47:51 +00:00
// FIXME: currentPlay/result doesn't always have description
2024-07-13 21:37:04 +00:00
desc := feed.LiveData.Plays.CurrentPlay.Result.Description
score, err := homeScore.Int64()
if err != nil {
return err
}
g.HomeScore = uint(score)
score, err = awayScore.Int64()
if err != nil {
return err
}
g.AwayScore = uint(score)
2024-07-04 04:52:40 +00:00
g.CurrPlayDesc = desc
2024-07-13 21:37:04 +00:00
return nil
2024-07-04 04:52:40 +00:00
}