Files
horse/race.go
T
zephyr 3bf17944b3
ci/woodpecker/push/horsebot Pipeline was successful
ci/woodpecker/push/zenno Pipeline failed
horse, mdb, cmd/horsebot: racecourses
2026-09-08 15:56:01 -04:00

96 lines
3.2 KiB
Go

package horse
type RaceID int32
// Race is the internal data about a race.
type Race struct {
ID RaceID `json:"race_id"`
Name string `json:"name"`
Thumbnail int `json:"thumbnail"`
// Some careers contain unusual versions of races, e.g. Tenno Sho (Spring)
// in Hanshin instead of Kyoto for Narita Taishin and Biwa Hayahide.
// For such races, this field holds the normal race ID.
Primary RaceID `json:"primary"`
}
type RaceTrackID int32
type RacecourseID int32
// Racecourse is interpreted race course data.
type Racecourse struct {
ID RacecourseID `json:"race_course_id"`
TrackID int32 `json:"race_track_id"`
TrackName string `json:"race_track_name"`
Distance float32 `json:"distance"`
Ground int8 `json:"ground"`
InOut int8 `json:"inout"`
Turn int8 `json:"turn"`
LaneMax TenThousandths `json:"lane_max"`
Threshold1 int8 `json:"threshold1,omitzero"`
Threshold2 int8 `json:"threshold2,omitzero"`
LaneStart [18]TenThousandths `json:"lane_start,omitzero"`
Spans []RacecourseSpan `json:"spans"`
Slopes []Slope `json:"slopes"`
MoveLanePoint float32 `json:"move_lane_point"`
}
// NOTE(zephyr): Racecourse.LaneStart is omitzero so that the JSON field is
// unsoundly undefined when the initial lane type is an unrecognized value.
// That should result in an error in the frontend, rather than a panic in the backend.
// RacecourseSpan is a span of a racecourse, which may be a straight, a corner,
// or a segment of the course which is neither a straight nor a corner.
type RacecourseSpan struct {
// Start is the distance in meters along the track at which the span starts.
Start float32 `json:"start"`
// End is the distance in meters along the track at which the span ends.
End float32 `json:"end"`
// Straight is whether the span is formally a straight.
Straight bool `json:"straight,omitzero"`
// FarStraight is whether the span is the backstretch.
// If true, then Straight is also true.
FarStraight bool `json:"far_straight,omitzero"`
// Corner is the corner number of the span, or zero if not a corner.
Corner int8 `json:"corner,omitzero"`
}
// Slope is a slope segment of a racecourse.
type Slope struct {
Per TenThousandths `json:"per"`
Start float32 `json:"start"`
End float32 `json:"end"`
}
type SaddleID int32
// Saddle is the internal data about a race win saddle.
type Saddle struct {
ID SaddleID `json:"saddle_id"`
Name string `json:"name"`
Races []RaceID `json:"races"`
Type SaddleType `json:"type"`
// Saddles that involve alternate races are themselves alternate.
// For such saddles, this field holds the normal saddle ID.
Primary SaddleID `json:"primary"`
}
type SaddleType int8
const (
// Saddle for multiple race wins, e.g. Classic Triple Crown, Dual Grand Prix, &c.
SaddleTypeHonor SaddleType = iota
SaddleTypeG3
SaddleTypeG2
SaddleTypeG1
)
type ScenarioID int8
// Scenario is metadata about a career scenario.
type Scenario struct {
ID ScenarioID `json:"scenario_id"`
Name string `json:"name"`
Title string `json:"title"`
}