Compare commits
2 Commits
332cf3f13a
...
34edcf97a7
| Author | SHA1 | Date | |
|---|---|---|---|
| 34edcf97a7 | |||
| 9dd18ed972 |
1574
doc/2026-01-29-global.diff
Normal file
1574
doc/2026-01-29-global.diff
Normal file
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,20 @@ pub struct skill-group-id
|
||||
pub struct skill-icon-id
|
||||
game-id: game-id
|
||||
|
||||
// Game ID for races,
|
||||
// i.e. "Tenno Sho (Spring)" and not "Tenno Sho (Spring) at Kyoto Racecourse."
|
||||
pub struct race-id
|
||||
game-id: game-id
|
||||
|
||||
// Game ID for race instances,
|
||||
// i.e. "Tenno Sho (Spring) at Kyoto Racecourse" vs. "Tenno Sho (Spring) at Hanshin."
|
||||
pub struct race-instance-id
|
||||
game-id: game-id
|
||||
|
||||
// Game ID for race thumbnails.
|
||||
pub struct race-thumbnail-id
|
||||
game-id: game-id
|
||||
|
||||
// order2 comparison between any game ID types.
|
||||
pub inline fun order2(x: a, y: a, ?a/game-id: (a) -> game-id): order2<a>
|
||||
match x.game-id.cmp(y.game-id)
|
||||
|
||||
2006
horse/global/race.go
Normal file
2006
horse/global/race.go
Normal file
File diff suppressed because it is too large
Load Diff
2044
horse/global/race.kk
Normal file
2044
horse/global/race.kk
Normal file
File diff suppressed because it is too large
Load Diff
17
horse/race.go
Normal file
17
horse/race.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package horse
|
||||
|
||||
type RaceID int32
|
||||
|
||||
// Race is the internal data about a race.
|
||||
//
|
||||
// Races may be offered multiple times in a career in different years.
|
||||
// Each separate offering is a different race instance of the same race.
|
||||
type Race struct {
|
||||
ID RaceID
|
||||
Name string
|
||||
Thumbnail int
|
||||
// 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
|
||||
}
|
||||
669
horse/race.kk
669
horse/race.kk
@@ -1,426 +1,30 @@
|
||||
module horse/race
|
||||
|
||||
import std/data/linearset
|
||||
import horse/game-id
|
||||
|
||||
// Exhaustive enumeration of graded races that can be run in career.
|
||||
// Races that can be run in multiple years are listed only once.
|
||||
pub type career-race
|
||||
February-Stakes
|
||||
Takamatsunomiya-Kinen
|
||||
Osaka-Hai
|
||||
Oka-Sho
|
||||
Satsuki-Sho
|
||||
Tenno-Sho-Spring
|
||||
NHK-Mile-Cup
|
||||
Victoria-Mile
|
||||
Japanese-Oaks
|
||||
Japanese-Derby
|
||||
Yasuda-Kinen
|
||||
Takarazuka-Kinen
|
||||
Sprinters-Stakes
|
||||
Shuka-Sho
|
||||
Kikuka-Sho
|
||||
Tenno-Sho-Autumn
|
||||
Queen-Elizabeth-II-Cup
|
||||
Mile-Championship
|
||||
Japan-Cup
|
||||
Champions-Cup
|
||||
Hanshin-Juvenile-Fillies
|
||||
Asahi-Hai-Futurity-Stakes
|
||||
Arima-Kinen
|
||||
Hopeful-Stakes
|
||||
Tokyo-Daishoten
|
||||
JBC-Classic
|
||||
JBC-Sprint
|
||||
JBC-Ladies-Classic
|
||||
Japan-Dirt-Derby
|
||||
Teio-Sho
|
||||
Nikkei-Shinshun-Hai
|
||||
Tokai-Stakes
|
||||
American-Jockey-Club-Cup
|
||||
Kyoto-Kinen
|
||||
Nakayama-Kinen
|
||||
Tulip-Sho
|
||||
Yayoi-Sho
|
||||
Kinko-Sho
|
||||
Fillies-Revue
|
||||
Hanshin-Daishoten
|
||||
Spring-Stakes
|
||||
Nikkei-Sho
|
||||
Hanshin-Umamusume-Stakes
|
||||
New-Zealand-Trophy
|
||||
Yomiuri-Milers-Cup
|
||||
Flora-Stakes
|
||||
Aoba-Sho
|
||||
Kyoto-Shimbun-Hai
|
||||
Keio-Hai-Spring-Cup
|
||||
Meguro-Kinen
|
||||
Sapporo-Kinen
|
||||
Centaur-Stakes
|
||||
Rose-Stakes
|
||||
St-Lite-Kinen
|
||||
Kobe-Shimbun-Hai
|
||||
All-Comers
|
||||
Mainichi-Okan
|
||||
Kyoto-Daishoten
|
||||
Fuchu-Umamusume-Stakes
|
||||
Fuji-Stakes
|
||||
Swan-Stakes
|
||||
Keio-Hai-Junior-Stakes
|
||||
Copa-Republica-Argentina
|
||||
Daily-Hai-Junior-Stakes
|
||||
Stayers-Stakes
|
||||
Hanshin-Cup
|
||||
Kyoto-Kimpai
|
||||
Nakayama-Kimpai
|
||||
Shinzan-Kinen
|
||||
Fairy-Stakes
|
||||
Aichi-Hai
|
||||
Keisei-Hai
|
||||
Silk-Road-Stakes
|
||||
Negishi-Stakes
|
||||
Kisaragi-Sho
|
||||
Tokyo-Shimbun-Hai
|
||||
Queen-Cup
|
||||
Kyodo-News-Hai
|
||||
Kyoto-Umamusume-Stakes
|
||||
Diamond-Stakes
|
||||
Kokura-Daishoten
|
||||
Arlington-Cup
|
||||
Hankyu-Hai
|
||||
Ocean-Stakes
|
||||
Nakayama-Umamusume-Stakes
|
||||
Falcon-Stakes
|
||||
Flower-Cup
|
||||
Mainichi-Hai
|
||||
March-Stakes
|
||||
Lord-Derby-Challenge-Trophy
|
||||
Antares-Stakes
|
||||
Fukushima-Umamusume-Stakes
|
||||
Niigata-Daishoten
|
||||
Heian-Stakes
|
||||
Aoi-Stakes
|
||||
Naruo-Kinen
|
||||
Mermaid-Stakes
|
||||
Epsom-Cup
|
||||
Unicorn-Stakes
|
||||
Hakodate-Sprint-Stakes
|
||||
CBC-Sho
|
||||
Radio-Nikkei-Sho
|
||||
Procyon-Stakes
|
||||
Tanabata-Sho
|
||||
Hakodate-Kinen
|
||||
Chukyo-Kinen
|
||||
Hakodate-Junior-Stakes
|
||||
Ibis-Summer-Dash
|
||||
Queen-Stakes
|
||||
Kokura-Kinen
|
||||
Leopard-Stakes
|
||||
Sekiya-Kinen
|
||||
Elm-Stakes
|
||||
Kitakyushu-Kinen
|
||||
Niigata-Junior-Stakes
|
||||
Keeneland-Cup
|
||||
Sapporo-Junior-Stakes
|
||||
Kokura-Junior-Stakes
|
||||
Niigata-Kinen
|
||||
Shion-Stakes
|
||||
Keisei-Hai-Autumn-Handicap
|
||||
Sirius-Stakes
|
||||
Saudi-Arabia-Royal-Cup
|
||||
Artemis-Stakes
|
||||
Fantasy-Stakes
|
||||
Miyako-Stakes
|
||||
Musashino-Stakes
|
||||
Fukushima-Kinen
|
||||
Tokyo-Sports-Hai-Junior-Stakes
|
||||
Kyoto-Junior-Stakes
|
||||
Keihan-Hai
|
||||
Challenge-Cup
|
||||
Chunichi-Shimbun-Hai
|
||||
Capella-Stakes
|
||||
Turquoise-Stakes
|
||||
pub struct race-detail
|
||||
race-id: race-id
|
||||
name: string
|
||||
grade: grade
|
||||
thumbnail-id: race-thumbnail-id
|
||||
// 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: race-id
|
||||
|
||||
// Automatically generated.
|
||||
// Shows a string representation of the `career-race` type.
|
||||
pub fun career-race/show(this : career-race) : e string
|
||||
match this
|
||||
February-Stakes -> "February Stakes"
|
||||
Takamatsunomiya-Kinen -> "Takamatsunomiya Kinen"
|
||||
Osaka-Hai -> "Osaka Hai"
|
||||
Oka-Sho -> "Oka Sho"
|
||||
Satsuki-Sho -> "Satsuki Sho"
|
||||
Tenno-Sho-Spring -> "Tenno Sho Spring"
|
||||
NHK-Mile-Cup -> "NHK Mile Cup"
|
||||
Victoria-Mile -> "Victoria Mile"
|
||||
Japanese-Oaks -> "Japanese Oaks"
|
||||
Japanese-Derby -> "Japanese Derby"
|
||||
Yasuda-Kinen -> "Yasuda Kinen"
|
||||
Takarazuka-Kinen -> "Takarazuka Kinen"
|
||||
Sprinters-Stakes -> "Sprinters Stakes"
|
||||
Shuka-Sho -> "Shuka Sho"
|
||||
Kikuka-Sho -> "Kikuka Sho"
|
||||
Tenno-Sho-Autumn -> "Tenno Sho Autumn"
|
||||
Queen-Elizabeth-II-Cup -> "Queen Elizabeth II Cup"
|
||||
Mile-Championship -> "Mile Championship"
|
||||
Japan-Cup -> "Japan Cup"
|
||||
Champions-Cup -> "Champions Cup"
|
||||
Hanshin-Juvenile-Fillies -> "Hanshin Juvenile Fillies"
|
||||
Asahi-Hai-Futurity-Stakes -> "Asahi Hai Futurity Stakes"
|
||||
Arima-Kinen -> "Arima Kinen"
|
||||
Hopeful-Stakes -> "Hopeful Stakes"
|
||||
Tokyo-Daishoten -> "Tokyo Daishoten"
|
||||
JBC-Classic -> "JBC Classic"
|
||||
JBC-Sprint -> "JBC Sprint"
|
||||
JBC-Ladies-Classic -> "JBC Ladies Classic"
|
||||
Japan-Dirt-Derby -> "Japan Dirt Derby"
|
||||
Teio-Sho -> "Teio Sho"
|
||||
Nikkei-Shinshun-Hai -> "Nikkei Shinshun Hai"
|
||||
Tokai-Stakes -> "Tokai Stakes"
|
||||
American-Jockey-Club-Cup -> "American Jockey Club Cup"
|
||||
Kyoto-Kinen -> "Kyoto Kinen"
|
||||
Nakayama-Kinen -> "Nakayama Kinen"
|
||||
Tulip-Sho -> "Tulip Sho"
|
||||
Yayoi-Sho -> "Yayoi Sho"
|
||||
Kinko-Sho -> "Kinko Sho"
|
||||
Fillies-Revue -> "Fillies Revue"
|
||||
Hanshin-Daishoten -> "Hanshin Daishoten"
|
||||
Spring-Stakes -> "Spring Stakes"
|
||||
Nikkei-Sho -> "Nikkei Sho"
|
||||
Hanshin-Umamusume-Stakes -> "Hanshin Umamusume Stakes"
|
||||
New-Zealand-Trophy -> "New Zealand Trophy"
|
||||
Yomiuri-Milers-Cup -> "Yomiuri Milers Cup"
|
||||
Flora-Stakes -> "Flora Stakes"
|
||||
Aoba-Sho -> "Aoba Sho"
|
||||
Kyoto-Shimbun-Hai -> "Kyoto Shimbun Hai"
|
||||
Keio-Hai-Spring-Cup -> "Keio Hai Spring Cup"
|
||||
Meguro-Kinen -> "Meguro Kinen"
|
||||
Sapporo-Kinen -> "Sapporo Kinen"
|
||||
Centaur-Stakes -> "Centaur Stakes"
|
||||
Rose-Stakes -> "Rose Stakes"
|
||||
St-Lite-Kinen -> "St Lite Kinen"
|
||||
Kobe-Shimbun-Hai -> "Kobe Shimbun Hai"
|
||||
All-Comers -> "All Comers"
|
||||
Mainichi-Okan -> "Mainichi Okan"
|
||||
Kyoto-Daishoten -> "Kyoto Daishoten"
|
||||
Fuchu-Umamusume-Stakes -> "Fuchu Umamusume Stakes"
|
||||
Fuji-Stakes -> "Fuji Stakes"
|
||||
Swan-Stakes -> "Swan Stakes"
|
||||
Keio-Hai-Junior-Stakes -> "Keio Hai Junior Stakes"
|
||||
Copa-Republica-Argentina -> "Copa Republica Argentina"
|
||||
Daily-Hai-Junior-Stakes -> "Daily Hai Junior Stakes"
|
||||
Stayers-Stakes -> "Stayers Stakes"
|
||||
Hanshin-Cup -> "Hanshin Cup"
|
||||
Kyoto-Kimpai -> "Kyoto Kimpai"
|
||||
Nakayama-Kimpai -> "Nakayama Kimpai"
|
||||
Shinzan-Kinen -> "Shinzan Kinen"
|
||||
Fairy-Stakes -> "Fairy Stakes"
|
||||
Aichi-Hai -> "Aichi Hai"
|
||||
Keisei-Hai -> "Keisei Hai"
|
||||
Silk-Road-Stakes -> "Silk Road Stakes"
|
||||
Negishi-Stakes -> "Negishi Stakes"
|
||||
Kisaragi-Sho -> "Kisaragi Sho"
|
||||
Tokyo-Shimbun-Hai -> "Tokyo Shimbun Hai"
|
||||
Queen-Cup -> "Queen Cup"
|
||||
Kyodo-News-Hai -> "Kyodo News Hai"
|
||||
Kyoto-Umamusume-Stakes -> "Kyoto Umamusume Stakes"
|
||||
Diamond-Stakes -> "Diamond Stakes"
|
||||
Kokura-Daishoten -> "Kokura Daishoten"
|
||||
Arlington-Cup -> "Arlington Cup"
|
||||
Hankyu-Hai -> "Hankyu Hai"
|
||||
Ocean-Stakes -> "Ocean Stakes"
|
||||
Nakayama-Umamusume-Stakes -> "Nakayama Umamusume Stakes"
|
||||
Falcon-Stakes -> "Falcon Stakes"
|
||||
Flower-Cup -> "Flower Cup"
|
||||
Mainichi-Hai -> "Mainichi Hai"
|
||||
March-Stakes -> "March Stakes"
|
||||
Lord-Derby-Challenge-Trophy -> "Lord Derby Challenge Trophy"
|
||||
Antares-Stakes -> "Antares Stakes"
|
||||
Fukushima-Umamusume-Stakes -> "Fukushima Umamusume Stakes"
|
||||
Niigata-Daishoten -> "Niigata Daishoten"
|
||||
Heian-Stakes -> "Heian Stakes"
|
||||
Aoi-Stakes -> "Aoi Stakes"
|
||||
Naruo-Kinen -> "Naruo Kinen"
|
||||
Mermaid-Stakes -> "Mermaid Stakes"
|
||||
Epsom-Cup -> "Epsom Cup"
|
||||
Unicorn-Stakes -> "Unicorn Stakes"
|
||||
Hakodate-Sprint-Stakes -> "Hakodate Sprint Stakes"
|
||||
CBC-Sho -> "CBC Sho"
|
||||
Radio-Nikkei-Sho -> "Radio Nikkei Sho"
|
||||
Procyon-Stakes -> "Procyon Stakes"
|
||||
Tanabata-Sho -> "Tanabata Sho"
|
||||
Hakodate-Kinen -> "Hakodate Kinen"
|
||||
Chukyo-Kinen -> "Chukyo Kinen"
|
||||
Hakodate-Junior-Stakes -> "Hakodate Junior Stakes"
|
||||
Ibis-Summer-Dash -> "Ibis Summer Dash"
|
||||
Queen-Stakes -> "Queen Stakes"
|
||||
Kokura-Kinen -> "Kokura Kinen"
|
||||
Leopard-Stakes -> "Leopard Stakes"
|
||||
Sekiya-Kinen -> "Sekiya Kinen"
|
||||
Elm-Stakes -> "Elm Stakes"
|
||||
Kitakyushu-Kinen -> "Kitakyushu Kinen"
|
||||
Niigata-Junior-Stakes -> "Niigata Junior Stakes"
|
||||
Keeneland-Cup -> "Keeneland Cup"
|
||||
Sapporo-Junior-Stakes -> "Sapporo Junior Stakes"
|
||||
Kokura-Junior-Stakes -> "Kokura Junior Stakes"
|
||||
Niigata-Kinen -> "Niigata Kinen"
|
||||
Shion-Stakes -> "Shion Stakes"
|
||||
Keisei-Hai-Autumn-Handicap -> "Keisei Hai Autumn Handicap"
|
||||
Sirius-Stakes -> "Sirius Stakes"
|
||||
Saudi-Arabia-Royal-Cup -> "Saudi Arabia Royal Cup"
|
||||
Artemis-Stakes -> "Artemis Stakes"
|
||||
Fantasy-Stakes -> "Fantasy Stakes"
|
||||
Miyako-Stakes -> "Miyako Stakes"
|
||||
Musashino-Stakes -> "Musashino Stakes"
|
||||
Fukushima-Kinen -> "Fukushima Kinen"
|
||||
Tokyo-Sports-Hai-Junior-Stakes -> "Tokyo Sports Hai Junior Stakes"
|
||||
Kyoto-Junior-Stakes -> "Kyoto Junior Stakes"
|
||||
Keihan-Hai -> "Keihan Hai"
|
||||
Challenge-Cup -> "Challenge Cup"
|
||||
Chunichi-Shimbun-Hai -> "Chunichi Shimbun Hai"
|
||||
Capella-Stakes -> "Capella Stakes"
|
||||
Turquoise-Stakes -> "Turquoise Stakes"
|
||||
pub fun detail(
|
||||
r: race-id,
|
||||
?race/show: (race-id) -> string,
|
||||
?race/grade: (race-id) -> grade,
|
||||
?race/thumbnail: (race-id) -> race-thumbnail-id,
|
||||
?race/primary: (race-id) -> race-id
|
||||
): race-detail
|
||||
Race-detail(r, r.show, r.grade, r.thumbnail, r.primary)
|
||||
|
||||
// Automatically generated.
|
||||
// Equality comparison of the `career-race` type.
|
||||
pub fun career-race/(==)(this : career-race, other : career-race) : e bool
|
||||
match (this, other)
|
||||
(February-Stakes, February-Stakes) -> True
|
||||
(Takamatsunomiya-Kinen, Takamatsunomiya-Kinen) -> True
|
||||
(Osaka-Hai, Osaka-Hai) -> True
|
||||
(Oka-Sho, Oka-Sho) -> True
|
||||
(Satsuki-Sho, Satsuki-Sho) -> True
|
||||
(Tenno-Sho-Spring, Tenno-Sho-Spring) -> True
|
||||
(NHK-Mile-Cup, NHK-Mile-Cup) -> True
|
||||
(Victoria-Mile, Victoria-Mile) -> True
|
||||
(Japanese-Oaks, Japanese-Oaks) -> True
|
||||
(Japanese-Derby, Japanese-Derby) -> True
|
||||
(Yasuda-Kinen, Yasuda-Kinen) -> True
|
||||
(Takarazuka-Kinen, Takarazuka-Kinen) -> True
|
||||
(Sprinters-Stakes, Sprinters-Stakes) -> True
|
||||
(Shuka-Sho, Shuka-Sho) -> True
|
||||
(Kikuka-Sho, Kikuka-Sho) -> True
|
||||
(Tenno-Sho-Autumn, Tenno-Sho-Autumn) -> True
|
||||
(Queen-Elizabeth-II-Cup, Queen-Elizabeth-II-Cup) -> True
|
||||
(Mile-Championship, Mile-Championship) -> True
|
||||
(Japan-Cup, Japan-Cup) -> True
|
||||
(Champions-Cup, Champions-Cup) -> True
|
||||
(Hanshin-Juvenile-Fillies, Hanshin-Juvenile-Fillies) -> True
|
||||
(Asahi-Hai-Futurity-Stakes, Asahi-Hai-Futurity-Stakes) -> True
|
||||
(Arima-Kinen, Arima-Kinen) -> True
|
||||
(Hopeful-Stakes, Hopeful-Stakes) -> True
|
||||
(Tokyo-Daishoten, Tokyo-Daishoten) -> True
|
||||
(JBC-Classic, JBC-Classic) -> True
|
||||
(JBC-Sprint, JBC-Sprint) -> True
|
||||
(JBC-Ladies-Classic, JBC-Ladies-Classic) -> True
|
||||
(Japan-Dirt-Derby, Japan-Dirt-Derby) -> True
|
||||
(Teio-Sho, Teio-Sho) -> True
|
||||
(Nikkei-Shinshun-Hai, Nikkei-Shinshun-Hai) -> True
|
||||
(Tokai-Stakes, Tokai-Stakes) -> True
|
||||
(American-Jockey-Club-Cup, American-Jockey-Club-Cup) -> True
|
||||
(Kyoto-Kinen, Kyoto-Kinen) -> True
|
||||
(Nakayama-Kinen, Nakayama-Kinen) -> True
|
||||
(Tulip-Sho, Tulip-Sho) -> True
|
||||
(Yayoi-Sho, Yayoi-Sho) -> True
|
||||
(Kinko-Sho, Kinko-Sho) -> True
|
||||
(Fillies-Revue, Fillies-Revue) -> True
|
||||
(Hanshin-Daishoten, Hanshin-Daishoten) -> True
|
||||
(Spring-Stakes, Spring-Stakes) -> True
|
||||
(Nikkei-Sho, Nikkei-Sho) -> True
|
||||
(Hanshin-Umamusume-Stakes, Hanshin-Umamusume-Stakes) -> True
|
||||
(New-Zealand-Trophy, New-Zealand-Trophy) -> True
|
||||
(Yomiuri-Milers-Cup, Yomiuri-Milers-Cup) -> True
|
||||
(Flora-Stakes, Flora-Stakes) -> True
|
||||
(Aoba-Sho, Aoba-Sho) -> True
|
||||
(Kyoto-Shimbun-Hai, Kyoto-Shimbun-Hai) -> True
|
||||
(Keio-Hai-Spring-Cup, Keio-Hai-Spring-Cup) -> True
|
||||
(Meguro-Kinen, Meguro-Kinen) -> True
|
||||
(Sapporo-Kinen, Sapporo-Kinen) -> True
|
||||
(Centaur-Stakes, Centaur-Stakes) -> True
|
||||
(Rose-Stakes, Rose-Stakes) -> True
|
||||
(St-Lite-Kinen, St-Lite-Kinen) -> True
|
||||
(Kobe-Shimbun-Hai, Kobe-Shimbun-Hai) -> True
|
||||
(All-Comers, All-Comers) -> True
|
||||
(Mainichi-Okan, Mainichi-Okan) -> True
|
||||
(Kyoto-Daishoten, Kyoto-Daishoten) -> True
|
||||
(Fuchu-Umamusume-Stakes, Fuchu-Umamusume-Stakes) -> True
|
||||
(Fuji-Stakes, Fuji-Stakes) -> True
|
||||
(Swan-Stakes, Swan-Stakes) -> True
|
||||
(Keio-Hai-Junior-Stakes, Keio-Hai-Junior-Stakes) -> True
|
||||
(Copa-Republica-Argentina, Copa-Republica-Argentina) -> True
|
||||
(Daily-Hai-Junior-Stakes, Daily-Hai-Junior-Stakes) -> True
|
||||
(Stayers-Stakes, Stayers-Stakes) -> True
|
||||
(Hanshin-Cup, Hanshin-Cup) -> True
|
||||
(Kyoto-Kimpai, Kyoto-Kimpai) -> True
|
||||
(Nakayama-Kimpai, Nakayama-Kimpai) -> True
|
||||
(Shinzan-Kinen, Shinzan-Kinen) -> True
|
||||
(Fairy-Stakes, Fairy-Stakes) -> True
|
||||
(Aichi-Hai, Aichi-Hai) -> True
|
||||
(Keisei-Hai, Keisei-Hai) -> True
|
||||
(Silk-Road-Stakes, Silk-Road-Stakes) -> True
|
||||
(Negishi-Stakes, Negishi-Stakes) -> True
|
||||
(Kisaragi-Sho, Kisaragi-Sho) -> True
|
||||
(Tokyo-Shimbun-Hai, Tokyo-Shimbun-Hai) -> True
|
||||
(Queen-Cup, Queen-Cup) -> True
|
||||
(Kyodo-News-Hai, Kyodo-News-Hai) -> True
|
||||
(Kyoto-Umamusume-Stakes, Kyoto-Umamusume-Stakes) -> True
|
||||
(Diamond-Stakes, Diamond-Stakes) -> True
|
||||
(Kokura-Daishoten, Kokura-Daishoten) -> True
|
||||
(Arlington-Cup, Arlington-Cup) -> True
|
||||
(Hankyu-Hai, Hankyu-Hai) -> True
|
||||
(Ocean-Stakes, Ocean-Stakes) -> True
|
||||
(Nakayama-Umamusume-Stakes, Nakayama-Umamusume-Stakes) -> True
|
||||
(Falcon-Stakes, Falcon-Stakes) -> True
|
||||
(Flower-Cup, Flower-Cup) -> True
|
||||
(Mainichi-Hai, Mainichi-Hai) -> True
|
||||
(March-Stakes, March-Stakes) -> True
|
||||
(Lord-Derby-Challenge-Trophy, Lord-Derby-Challenge-Trophy) -> True
|
||||
(Antares-Stakes, Antares-Stakes) -> True
|
||||
(Fukushima-Umamusume-Stakes, Fukushima-Umamusume-Stakes) -> True
|
||||
(Niigata-Daishoten, Niigata-Daishoten) -> True
|
||||
(Heian-Stakes, Heian-Stakes) -> True
|
||||
(Aoi-Stakes, Aoi-Stakes) -> True
|
||||
(Naruo-Kinen, Naruo-Kinen) -> True
|
||||
(Mermaid-Stakes, Mermaid-Stakes) -> True
|
||||
(Epsom-Cup, Epsom-Cup) -> True
|
||||
(Unicorn-Stakes, Unicorn-Stakes) -> True
|
||||
(Hakodate-Sprint-Stakes, Hakodate-Sprint-Stakes) -> True
|
||||
(CBC-Sho, CBC-Sho) -> True
|
||||
(Radio-Nikkei-Sho, Radio-Nikkei-Sho) -> True
|
||||
(Procyon-Stakes, Procyon-Stakes) -> True
|
||||
(Tanabata-Sho, Tanabata-Sho) -> True
|
||||
(Hakodate-Kinen, Hakodate-Kinen) -> True
|
||||
(Chukyo-Kinen, Chukyo-Kinen) -> True
|
||||
(Hakodate-Junior-Stakes, Hakodate-Junior-Stakes) -> True
|
||||
(Ibis-Summer-Dash, Ibis-Summer-Dash) -> True
|
||||
(Queen-Stakes, Queen-Stakes) -> True
|
||||
(Kokura-Kinen, Kokura-Kinen) -> True
|
||||
(Leopard-Stakes, Leopard-Stakes) -> True
|
||||
(Sekiya-Kinen, Sekiya-Kinen) -> True
|
||||
(Elm-Stakes, Elm-Stakes) -> True
|
||||
(Kitakyushu-Kinen, Kitakyushu-Kinen) -> True
|
||||
(Niigata-Junior-Stakes, Niigata-Junior-Stakes) -> True
|
||||
(Keeneland-Cup, Keeneland-Cup) -> True
|
||||
(Sapporo-Junior-Stakes, Sapporo-Junior-Stakes) -> True
|
||||
(Kokura-Junior-Stakes, Kokura-Junior-Stakes) -> True
|
||||
(Niigata-Kinen, Niigata-Kinen) -> True
|
||||
(Shion-Stakes, Shion-Stakes) -> True
|
||||
(Keisei-Hai-Autumn-Handicap, Keisei-Hai-Autumn-Handicap) -> True
|
||||
(Sirius-Stakes, Sirius-Stakes) -> True
|
||||
(Saudi-Arabia-Royal-Cup, Saudi-Arabia-Royal-Cup) -> True
|
||||
(Artemis-Stakes, Artemis-Stakes) -> True
|
||||
(Fantasy-Stakes, Fantasy-Stakes) -> True
|
||||
(Miyako-Stakes, Miyako-Stakes) -> True
|
||||
(Musashino-Stakes, Musashino-Stakes) -> True
|
||||
(Fukushima-Kinen, Fukushima-Kinen) -> True
|
||||
(Tokyo-Sports-Hai-Junior-Stakes, Tokyo-Sports-Hai-Junior-Stakes) -> True
|
||||
(Kyoto-Junior-Stakes, Kyoto-Junior-Stakes) -> True
|
||||
(Keihan-Hai, Keihan-Hai) -> True
|
||||
(Challenge-Cup, Challenge-Cup) -> True
|
||||
(Chunichi-Shimbun-Hai, Chunichi-Shimbun-Hai) -> True
|
||||
(Capella-Stakes, Capella-Stakes) -> True
|
||||
(Turquoise-Stakes, Turquoise-Stakes) -> True
|
||||
(_, _) -> False
|
||||
pub fun race-detail/show(r: race-detail): string
|
||||
val Race-detail(Race-id(id), name) = r
|
||||
name ++ " (ID " ++ id.show ++ ")"
|
||||
|
||||
// Race grades.
|
||||
pub type grade
|
||||
@@ -431,230 +35,9 @@ pub type grade
|
||||
G1
|
||||
EX
|
||||
|
||||
pub fun career-race/grade(r: career-race): grade
|
||||
match r
|
||||
February-Stakes -> G1
|
||||
Takamatsunomiya-Kinen -> G1
|
||||
Osaka-Hai -> G1
|
||||
Oka-Sho -> G1
|
||||
Satsuki-Sho -> G1
|
||||
Tenno-Sho-Spring -> G1
|
||||
NHK-Mile-Cup -> G1
|
||||
Victoria-Mile -> G1
|
||||
Japanese-Oaks -> G1
|
||||
Japanese-Derby -> G1
|
||||
Yasuda-Kinen -> G1
|
||||
Takarazuka-Kinen -> G1
|
||||
Sprinters-Stakes -> G1
|
||||
Shuka-Sho -> G1
|
||||
Kikuka-Sho -> G1
|
||||
Tenno-Sho-Autumn -> G1
|
||||
Queen-Elizabeth-II-Cup -> G1
|
||||
Mile-Championship -> G1
|
||||
Japan-Cup -> G1
|
||||
Champions-Cup -> G1
|
||||
Hanshin-Juvenile-Fillies -> G1
|
||||
Asahi-Hai-Futurity-Stakes -> G1
|
||||
Arima-Kinen -> G1
|
||||
Hopeful-Stakes -> G1
|
||||
Tokyo-Daishoten -> G1
|
||||
JBC-Classic -> G1
|
||||
JBC-Sprint -> G1
|
||||
JBC-Ladies-Classic -> G1
|
||||
Japan-Dirt-Derby -> G1
|
||||
Teio-Sho -> G1
|
||||
Nikkei-Shinshun-Hai -> G2
|
||||
Tokai-Stakes -> G2
|
||||
American-Jockey-Club-Cup -> G2
|
||||
Kyoto-Kinen -> G2
|
||||
Nakayama-Kinen -> G2
|
||||
Tulip-Sho -> G2
|
||||
Yayoi-Sho -> G2
|
||||
Kinko-Sho -> G2
|
||||
Fillies-Revue -> G2
|
||||
Hanshin-Daishoten -> G2
|
||||
Spring-Stakes -> G2
|
||||
Nikkei-Sho -> G2
|
||||
Hanshin-Umamusume-Stakes -> G2
|
||||
New-Zealand-Trophy -> G2
|
||||
Yomiuri-Milers-Cup -> G2
|
||||
Flora-Stakes -> G2
|
||||
Aoba-Sho -> G2
|
||||
Kyoto-Shimbun-Hai -> G2
|
||||
Keio-Hai-Spring-Cup -> G2
|
||||
Meguro-Kinen -> G2
|
||||
Sapporo-Kinen -> G2
|
||||
Centaur-Stakes -> G2
|
||||
Rose-Stakes -> G2
|
||||
St-Lite-Kinen -> G2
|
||||
Kobe-Shimbun-Hai -> G2
|
||||
All-Comers -> G2
|
||||
Mainichi-Okan -> G2
|
||||
Kyoto-Daishoten -> G2
|
||||
Fuchu-Umamusume-Stakes -> G2
|
||||
Fuji-Stakes -> G2
|
||||
Swan-Stakes -> G2
|
||||
Keio-Hai-Junior-Stakes -> G2
|
||||
Copa-Republica-Argentina -> G2
|
||||
Daily-Hai-Junior-Stakes -> G2
|
||||
Stayers-Stakes -> G2
|
||||
Hanshin-Cup -> G2
|
||||
Kyoto-Kimpai -> G3
|
||||
Nakayama-Kimpai -> G3
|
||||
Shinzan-Kinen -> G3
|
||||
Fairy-Stakes -> G3
|
||||
Aichi-Hai -> G3
|
||||
Keisei-Hai -> G3
|
||||
Silk-Road-Stakes -> G3
|
||||
Negishi-Stakes -> G3
|
||||
Kisaragi-Sho -> G3
|
||||
Tokyo-Shimbun-Hai -> G3
|
||||
Queen-Cup -> G3
|
||||
Kyodo-News-Hai -> G3
|
||||
Kyoto-Umamusume-Stakes -> G3
|
||||
Diamond-Stakes -> G3
|
||||
Kokura-Daishoten -> G3
|
||||
Arlington-Cup -> G3
|
||||
Hankyu-Hai -> G3
|
||||
Ocean-Stakes -> G3
|
||||
Nakayama-Umamusume-Stakes -> G3
|
||||
Falcon-Stakes -> G3
|
||||
Flower-Cup -> G3
|
||||
Mainichi-Hai -> G3
|
||||
March-Stakes -> G3
|
||||
Lord-Derby-Challenge-Trophy -> G3
|
||||
Antares-Stakes -> G3
|
||||
Fukushima-Umamusume-Stakes -> G3
|
||||
Niigata-Daishoten -> G3
|
||||
Heian-Stakes -> G3
|
||||
Aoi-Stakes -> G3
|
||||
Naruo-Kinen -> G3
|
||||
Mermaid-Stakes -> G3
|
||||
Epsom-Cup -> G3
|
||||
Unicorn-Stakes -> G3
|
||||
Hakodate-Sprint-Stakes -> G3
|
||||
CBC-Sho -> G3
|
||||
Radio-Nikkei-Sho -> G3
|
||||
Procyon-Stakes -> G3
|
||||
Tanabata-Sho -> G3
|
||||
Hakodate-Kinen -> G3
|
||||
Chukyo-Kinen -> G3
|
||||
Hakodate-Junior-Stakes -> G3
|
||||
Ibis-Summer-Dash -> G3
|
||||
Queen-Stakes -> G3
|
||||
Kokura-Kinen -> G3
|
||||
Leopard-Stakes -> G3
|
||||
Sekiya-Kinen -> G3
|
||||
Elm-Stakes -> G3
|
||||
Kitakyushu-Kinen -> G3
|
||||
Niigata-Junior-Stakes -> G3
|
||||
Keeneland-Cup -> G3
|
||||
Sapporo-Junior-Stakes -> G3
|
||||
Kokura-Junior-Stakes -> G3
|
||||
Niigata-Kinen -> G3
|
||||
Shion-Stakes -> G3
|
||||
Keisei-Hai-Autumn-Handicap -> G3
|
||||
Sirius-Stakes -> G3
|
||||
Saudi-Arabia-Royal-Cup -> G3
|
||||
Artemis-Stakes -> G3
|
||||
Fantasy-Stakes -> G3
|
||||
Miyako-Stakes -> G3
|
||||
Musashino-Stakes -> G3
|
||||
Fukushima-Kinen -> G3
|
||||
Tokyo-Sports-Hai-Junior-Stakes -> G3
|
||||
Kyoto-Junior-Stakes -> G3
|
||||
Keihan-Hai -> G3
|
||||
Challenge-Cup -> G3
|
||||
Chunichi-Shimbun-Hai -> G3
|
||||
Capella-Stakes -> G3
|
||||
Turquoise-Stakes -> G3
|
||||
|
||||
pub type title
|
||||
Classic-Triple-Crown
|
||||
Triple-Tiara
|
||||
Senior-Spring-Triple-Crown
|
||||
Senior-Autumn-Triple-Crown
|
||||
Tenno-Sweep
|
||||
Dual-Grand-Prix
|
||||
Dual-Miles
|
||||
Dual-Sprints
|
||||
Dual-Dirts
|
||||
|
||||
// Get the titles that a race contributes to.
|
||||
inline fun career-race/titles(r: career-race): list<title>
|
||||
match r
|
||||
Satsuki-Sho -> [Classic-Triple-Crown]
|
||||
Japanese-Derby -> [Classic-Triple-Crown]
|
||||
Kikuka-Sho -> [Classic-Triple-Crown]
|
||||
Oka-Sho -> [Triple-Tiara]
|
||||
Japanese-Oaks -> [Triple-Tiara]
|
||||
Shuka-Sho -> [Triple-Tiara]
|
||||
Osaka-Hai -> [Senior-Spring-Triple-Crown]
|
||||
Tenno-Sho-Spring -> [Senior-Spring-Triple-Crown, Tenno-Sweep]
|
||||
Takarazuka-Kinen -> [Senior-Spring-Triple-Crown, Dual-Grand-Prix]
|
||||
Tenno-Sho-Autumn -> [Senior-Autumn-Triple-Crown, Tenno-Sweep]
|
||||
Japan-Cup -> [Senior-Autumn-Triple-Crown]
|
||||
Arima-Kinen -> [Senior-Autumn-Triple-Crown, Dual-Grand-Prix]
|
||||
Yasuda-Kinen -> [Dual-Miles]
|
||||
Mile-Championship -> [Dual-Miles]
|
||||
Takamatsunomiya-Kinen -> [Dual-Sprints]
|
||||
Sprinters-Stakes -> [Dual-Sprints]
|
||||
February-Stakes -> [Dual-Dirts]
|
||||
Champions-Cup -> [Dual-Dirts]
|
||||
_ -> []
|
||||
|
||||
// Get the races that a title requires.
|
||||
inline fun title/races(t: title): list<career-race>
|
||||
match t
|
||||
Classic-Triple-Crown -> [Satsuki-Sho, Japanese-Derby, Kikuka-Sho]
|
||||
Triple-Tiara -> [Oka-Sho, Japanese-Oaks, Shuka-Sho]
|
||||
Senior-Spring-Triple-Crown -> [Osaka-Hai, Tenno-Sho-Spring, Takarazuka-Kinen]
|
||||
Senior-Autumn-Triple-Crown -> [Tenno-Sho-Autumn, Japan-Cup, Arima-Kinen]
|
||||
Tenno-Sweep -> [Tenno-Sho-Spring, Tenno-Sho-Autumn]
|
||||
Dual-Grand-Prix -> [Takarazuka-Kinen, Arima-Kinen]
|
||||
Dual-Miles -> [Yasuda-Kinen, Mile-Championship]
|
||||
Dual-Sprints -> [Takamatsunomiya-Kinen, Sprinters-Stakes]
|
||||
Dual-Dirts -> [February-Stakes, Champions-Cup]
|
||||
|
||||
// Get all titles earned by an uma.
|
||||
pub fun career/titles(results: list<race-result>): list<title>
|
||||
val wins = results.flatmap-maybe() fn(r) (if r.place == 1 then Just(r.race) else Nothing)
|
||||
val title-wins = wins.filter(_.titles.is-cons).linear-set
|
||||
val titles = title-wins.list.flatmap(_.titles).linear-set.list
|
||||
titles.filter(_.races.linear-set.is-subset-of(title-wins))
|
||||
|
||||
// Automatically generated.
|
||||
// Equality comparison of the `title` type.
|
||||
pub fun title/(==)(this : title, other : title) : e bool
|
||||
match (this, other)
|
||||
(Classic-Triple-Crown, Classic-Triple-Crown) -> True
|
||||
(Triple-Tiara, Triple-Tiara) -> True
|
||||
(Senior-Spring-Triple-Crown, Senior-Spring-Triple-Crown) -> True
|
||||
(Senior-Autumn-Triple-Crown, Senior-Autumn-Triple-Crown) -> True
|
||||
(Tenno-Sweep, Tenno-Sweep) -> True
|
||||
(Dual-Grand-Prix, Dual-Grand-Prix) -> True
|
||||
(Dual-Miles, Dual-Miles) -> True
|
||||
(Dual-Sprints, Dual-Sprints) -> True
|
||||
(Dual-Dirts, Dual-Dirts) -> True
|
||||
(_, _) -> False
|
||||
|
||||
// Automatically generated.
|
||||
// Shows a string representation of the `title` type.
|
||||
pub fun title/show(this : title) : e string
|
||||
match this
|
||||
Classic-Triple-Crown -> "Classic Triple Crown"
|
||||
Triple-Tiara -> "Triple Tiara"
|
||||
Senior-Spring-Triple-Crown -> "Senior Spring Triple Crown"
|
||||
Senior-Autumn-Triple-Crown -> "Senior Autumn Triple Crown"
|
||||
Tenno-Sweep -> "Tenno Sweep"
|
||||
Dual-Grand-Prix -> "Dual Grand Prix"
|
||||
Dual-Miles -> "Dual Miles"
|
||||
Dual-Sprints -> "Dual Sprints"
|
||||
Dual-Dirts -> "Dual Dirts"
|
||||
|
||||
// Graded race that a veteran ran.
|
||||
pub struct race-result
|
||||
race: career-race
|
||||
race-id: race-id
|
||||
place: int
|
||||
turn: turn
|
||||
|
||||
@@ -666,14 +49,14 @@ pub fun race-result/(==)(this : race-result, other : race-result) : e bool
|
||||
|
||||
// Automatically generated.
|
||||
// Shows a string representation of the `race-result` type.
|
||||
pub fun race-result/show(this : race-result) : e string
|
||||
pub fun race-result/show(this : race-result, ?race/show: (race-id) -> string) : e string
|
||||
match this
|
||||
Race-result(race, place, turn) -> turn.show ++ " " ++ race.show ++ ": " ++ place.show
|
||||
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(a: race-result, b: race-result): bool
|
||||
a.race == b.race
|
||||
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
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"unicode"
|
||||
)
|
||||
|
||||
//go:embed character.kk.template skill.kk.template character.go.template skill.go.template
|
||||
//go:embed character.kk.template skill.kk.template character.go.template skill.go.template race.kk.template race.go.template
|
||||
var templates embed.FS
|
||||
|
||||
// LoadTemplates sets up templates to render game data to source code.
|
||||
@@ -93,6 +93,21 @@ func ExecSkill(t *template.Template, region string, kk, g io.Writer, groups []Na
|
||||
return err
|
||||
}
|
||||
|
||||
func ExecRace(t *template.Template, region string, kk, g io.Writer, races []Race) error {
|
||||
data := struct {
|
||||
Region string
|
||||
Races []Race
|
||||
}{region, races}
|
||||
var err error
|
||||
if kk != nil {
|
||||
err = errors.Join(err, t.ExecuteTemplate(kk, "koka-race", &data))
|
||||
}
|
||||
if g != nil {
|
||||
err = errors.Join(err, t.ExecuteTemplate(g, "go-race", &data))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
const wordSeps = " ,!?/-+();#○☆♡'=♪∀゚∴"
|
||||
|
||||
var (
|
||||
@@ -105,11 +120,12 @@ var (
|
||||
"114th", "Hundred-Fourteenth",
|
||||
"♡ 3D Nail Art", "Nail-Art",
|
||||
".", "",
|
||||
"\u2019", "",
|
||||
"&", "-and-",
|
||||
"'s", "s",
|
||||
"ó", "o",
|
||||
"∞", "Infinity",
|
||||
"×", "x",
|
||||
"\u00d7", "x",
|
||||
"◎", "Lv2",
|
||||
}
|
||||
for _, c := range wordSeps {
|
||||
@@ -128,10 +144,11 @@ var (
|
||||
"1st", "First",
|
||||
"♡ 3D Nail Art", "NailArt",
|
||||
".", "",
|
||||
"\u2019", "",
|
||||
"&", "And",
|
||||
"'s", "s",
|
||||
"∞", "Infinity",
|
||||
"×", "X",
|
||||
"\u00d7", "X",
|
||||
"◎", "Lv2",
|
||||
}
|
||||
for _, c := range wordSeps {
|
||||
|
||||
@@ -23,6 +23,9 @@ var skillGroupSQL string
|
||||
//go:embed skill.sql
|
||||
var skillSQL string
|
||||
|
||||
//go:embed race.sql
|
||||
var raceSQL string
|
||||
|
||||
type (
|
||||
Character struct{}
|
||||
SkillGroup struct{}
|
||||
@@ -315,3 +318,44 @@ func Skills(ctx context.Context, db *sqlitex.Pool) ([]Skill, error) {
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
type Race struct {
|
||||
ID int
|
||||
Name string
|
||||
Grade int
|
||||
ThumbnailID int
|
||||
Primary int
|
||||
}
|
||||
|
||||
func Races(ctx context.Context, db *sqlitex.Pool) ([]Race, error) {
|
||||
conn, err := db.Take(ctx)
|
||||
defer db.Put(conn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't get connection for races: %w", err)
|
||||
}
|
||||
stmt, _, err := conn.PrepareTransient(raceSQL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't prepare statement for races: %w", err)
|
||||
}
|
||||
defer stmt.Finalize()
|
||||
|
||||
var r []Race
|
||||
for {
|
||||
ok, err := stmt.Step()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error stepping races: %w", err)
|
||||
}
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
race := Race{
|
||||
ID: stmt.ColumnInt(0),
|
||||
Name: stmt.ColumnText(1),
|
||||
Grade: stmt.ColumnInt(2),
|
||||
ThumbnailID: stmt.ColumnInt(3),
|
||||
Primary: stmt.ColumnInt(4),
|
||||
}
|
||||
r = append(r, race)
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ func main() {
|
||||
trios []AffinityRelation
|
||||
sg []NamedID[SkillGroup]
|
||||
skills []Skill
|
||||
races []Race
|
||||
)
|
||||
eg.Go(func() error {
|
||||
slog.Info("get characters")
|
||||
@@ -81,6 +82,12 @@ func main() {
|
||||
skills = r
|
||||
return err
|
||||
})
|
||||
eg.Go(func() error {
|
||||
slog.Info("get races")
|
||||
r, err := Races(ctx, db)
|
||||
races = r
|
||||
return err
|
||||
})
|
||||
if err := eg.Wait(); err != nil {
|
||||
slog.Error("load", slog.Any("err", err))
|
||||
os.Exit(1)
|
||||
@@ -116,8 +123,21 @@ func main() {
|
||||
slog.Info("write skills")
|
||||
return ExecSkill(t, region, sf, gf, sg, skills)
|
||||
})
|
||||
eg.Go(func() error {
|
||||
kf, err := os.Create(filepath.Join(out, region, "race.kk"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gf, err := os.Create(filepath.Join(out, region, "race.go"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
slog.Info("write races")
|
||||
return ExecRace(t, region, kf, gf, races)
|
||||
})
|
||||
if err := eg.Wait(); err != nil {
|
||||
slog.Error("generate", slog.Any("err", err))
|
||||
os.Exit(1)
|
||||
} else {
|
||||
slog.Info("done")
|
||||
}
|
||||
|
||||
32
horsegen/race.go.template
Normal file
32
horsegen/race.go.template
Normal file
@@ -0,0 +1,32 @@
|
||||
{{- define "go-race" -}}
|
||||
package {{ $.Region }}
|
||||
|
||||
// Automatically generated with horsegen; DO NOT EDIT
|
||||
|
||||
import . "git.sunturtle.xyz/zephyr/horse/horse"
|
||||
|
||||
const (
|
||||
{{- range $r := $.Races }}
|
||||
Race{{ goenum $r.Name }}{{ if ne $r.Primary $r.ID }}Alternate{{ end }} RaceID = {{ $r.ID }} // {{ $r.Name }}
|
||||
{{- end }}
|
||||
)
|
||||
|
||||
var AllRaces = map[RaceID]Race{
|
||||
{{- range $r := $.Races }}
|
||||
Race{{ goenum $r.Name }}{{ if ne $r.Primary $r.ID }}Alternate{{ end }}: {
|
||||
ID: {{ $r.ID }},
|
||||
Name: {{ printf "%q" $r.Name }}{{ if ne $r.Primary $r.ID }} + " (Alternate)"{{ end }},
|
||||
Thumbnail: {{ $r.ThumbnailID }},
|
||||
{{- if ne $r.Primary $r.ID }}
|
||||
Primary: {{ $r.Primary }},
|
||||
{{- end }}
|
||||
},
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
var RaceNameToID = map[string]RaceID{
|
||||
{{- range $r := $.Races }}
|
||||
{{ printf "%q" $r.Name }}{{ if ne $r.Primary $r.ID }} + " (Alternate)"{{ end }}: {{ $r.ID }},
|
||||
{{- end }}
|
||||
}
|
||||
{{ end }}
|
||||
80
horsegen/race.kk.template
Normal file
80
horsegen/race.kk.template
Normal file
@@ -0,0 +1,80 @@
|
||||
{{- define "koka-race" -}}
|
||||
module horse/{{ $.Region }}/race
|
||||
|
||||
// Automatically generated with horsegen; DO NOT EDIT
|
||||
|
||||
import std/data/rb-map
|
||||
import horse/game-id
|
||||
pub import horse/race
|
||||
|
||||
// Enumeration of all races for type-safe programming.
|
||||
pub type race
|
||||
{{- range $r := $.Races }}
|
||||
{{ kkenum $r.Name }}{{ if ne $r.Primary $r.ID }}-Alternate{{ end }}
|
||||
{{- end }}
|
||||
|
||||
// Get the race ID for a race.
|
||||
pub fun race-id(r: race): race-id
|
||||
match r
|
||||
{{- range $r := $.Races }}
|
||||
{{ kkenum $r.Name }}{{ if ne $r.Primary $r.ID }}-Alternate{{ end }} -> Race-id({{ $r.ID }})
|
||||
{{- end }}
|
||||
|
||||
// List of all races in ID order for easy iterating.
|
||||
pub val all = [
|
||||
{{- range $r := $.Races }}
|
||||
{{ kkenum $r.Name }}{{ if ne $r.Primary $r.ID }}-Alternate{{ end }},
|
||||
{{- end }}
|
||||
]
|
||||
|
||||
val name2id: rbmap<string, race-id> = rb-map/empty()
|
||||
{{- range $r := $.Races }}
|
||||
.set({{ printf "%q" $r.Name }}{{ if ne $r.Primary $r.ID }} ++ " (Alternate)"{{ end }}, Race-id({{ $r.ID }}))
|
||||
{{- end }}
|
||||
|
||||
// Get the race ID that has the given exact name.
|
||||
// Alternate versions of races have " (Alternate)" in their names.
|
||||
// If no race matches the name, the result is an invalid ID.
|
||||
pub fun from-name(name: string): race-id
|
||||
name2id.lookup(name).default(Race-id(0))
|
||||
|
||||
// Get the name for a race.
|
||||
// Alternate versions of races have " (Alternate)" in their names.
|
||||
// If no race matches the ID, the result is the numeric ID.
|
||||
pub fun show(r: race-id): string
|
||||
match r.game-id
|
||||
{{- range $r := $.Races }}
|
||||
{{ $r.ID }} -> {{ printf "%q" $r.Name }}{{ if ne $r.Primary $r.ID }} ++ " (Alternate)"{{ end }}
|
||||
{{- end }}
|
||||
x -> "race " ++ x.show
|
||||
|
||||
// Get the grade for a race.
|
||||
// If no race matches the ID, the result is Pre-OP.
|
||||
pub fun grade(r: race-id): grade
|
||||
match r.game-id
|
||||
{{- range $r := $.Races }}
|
||||
{{ $r.ID }} -> {{ if eq $r.Grade 100 }}G1{{ else if eq $r.Grade 200 }}G2{{ else if eq $r.Grade 300 }}G3{{ else if eq $r.Grade 400 }}OP{{ else if eq $r.Grade 700 }}Pre-OP{{ else }}??? $r.Grade={{ $r.Grade }}{{ end }}
|
||||
{{- end }}
|
||||
_ -> Pre-OP
|
||||
|
||||
// Get the thumbnail ID for a race.
|
||||
// If no race matches the ID, the result is an invalid ID.
|
||||
pub fun thumbnail(r: race-id): race-thumbnail-id
|
||||
match r.game-id
|
||||
{{- range $r := $.Races }}
|
||||
{{ $r.ID }} -> Race-thumbnail-id({{ $r.ThumbnailID }})
|
||||
{{- end }}
|
||||
_ -> Race-thumbnail-id(0)
|
||||
|
||||
// Get the primary ID for a race.
|
||||
// For races which are the primary version, or if no race matches the given ID,
|
||||
// the result is the input.
|
||||
pub fun primary(r: race-id): race-id
|
||||
match r.game-id
|
||||
{{- range $r := $.Races }}
|
||||
{{- if ne $r.ID $r.Primary }}
|
||||
{{ $r.ID }} -> Race-id({{ $r.Primary }})
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
_ -> r
|
||||
{{ end }}
|
||||
13
horsegen/race.sql
Normal file
13
horsegen/race.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
WITH race_names AS (
|
||||
SELECT "index" AS id, "text" AS name FROM text_data WHERE category = 33
|
||||
)
|
||||
SELECT
|
||||
race.id,
|
||||
race_names.name,
|
||||
race.grade,
|
||||
race.thumbnail_id,
|
||||
MIN(race.id) OVER (PARTITION BY race_names.name) AS "primary"
|
||||
FROM race
|
||||
JOIN race_names ON race.id = race_names.id
|
||||
WHERE race."group" = 1
|
||||
ORDER BY race.id
|
||||
Reference in New Issue
Block a user