horse: rearrange career race results

This commit is contained in:
2026-02-01 15:31:46 -05:00
parent f3f070ca2b
commit bf06de0f5e
2 changed files with 25 additions and 20 deletions

View File

@@ -67,29 +67,12 @@ pub fun grade/show(this : grade) : e string
G1 -> "G1"
EX -> "EX"
// Graded race that a veteran ran.
pub struct race-result
// Instance of a race.
pub struct race-instance-detail
race-instance-id: race-instance-id
race-id: race-id
place: int
turn: turn
// Automatically generated.
// Equality comparison of the `race-result` type.
pub fun race-result/(==)(this : race-result, other : race-result) : e bool
match (this, other)
(Race-result(race, place, turn), Race-result(race', place', turn')) -> race == race' && place == place' && turn == turn'
// Automatically generated.
// Shows a string representation of the `race-result` type.
pub fun race-result/show(this : race-result, ?race/show: (race-id) -> string) : e string
match this
Race-result(race-id, place, turn) -> turn.show ++ " " ++ race-id.show ++ ": " ++ place.show
// Determine whether two race results are for the same race.
// This differs from (==) which also requires the race to be on the same turn.
pub fun race-result/same-race(a: race-result, b: race-result): bool
a.race-id == b.race-id
// Turn that a race occurred.
pub struct turn
year: turn-year

View File

@@ -1,5 +1,6 @@
module horse/trainee
import horse/game-id
import horse/movement
// Details of a trainee.
@@ -14,3 +15,24 @@ pub struct trainee-detail
pace-chaser: level
late-surger: level
end-closer: level
// Graded race that a veteran ran.
pub struct race-result
race-id: race-id
race-instance-id: race-instance-id
place: int
// Automatically generated.
// Equality comparison of the `race-result` type.
pub fun race-result/(==)(this : race-result, other : race-result) : e bool
match (this, other)
(Race-result(race-id, race-instance-id, place), Race-result(race-id', race-instance-id', place')) -> race-id == race-id' && race-instance-id == race-instance-id' && place == place'
pub fun race-result/show(r: race-result, ?race/show: (race-id) -> string) : e string
val Race-result(race, _, place) = r
race.show ++ ": " ++ place.show
// Determine whether two race results are for the same race.
// This differs from (==) which also requires the race to be on the same turn.
pub fun race-result/same-race(a: race-result, b: race-result): bool
a.race-id == b.race-id