horsegen: generate umas

This commit is contained in:
2026-02-26 19:02:49 -05:00
parent 3fa30903cd
commit 7972bab46c
13 changed files with 3747 additions and 15 deletions

221
horsegen/uma.kk.template Normal file
View File

@@ -0,0 +1,221 @@
{{- define "koka-uma" -}}
module horse/{{ $.Region }}/uma
// Automatically generated with horsegen; DO NOT EDIT
import std/core/delayed
import std/core/vector
import std/core-extras
import horse/game-id
import horse/movement
pub import horse/uma
extern create-id-table(): vector<int>
c inline "int32_t arr[] = { {{- range $uma := $.Umas }}{{ $uma.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.UmaCount }}, kk_context())"
js inline "[{{ range $uma := $.Umas }}{{ $uma.ID }},{{ end }}]"
// Vector of all Uma IDs in order for easy iterating.
val vall = once(create-id-table)
// Get the name for an Uma.
// The name includes the costume variant, e.g. `[Special Dreamer] Special Week`.
// If no Uma matches the ID, the result contains the numeric ID.
pub fun show(uma: uma-id): string
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ printf "%q" $uma.Name }}
{{- end }}
x -> "uma " ++ x.show
// Get the costume variant for an Uma, e.g. `[Special Dreamer]`.
// If no Uma matches the ID, the result contains the numeric ID.
pub fun variant(uma: uma-id): string
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ printf "%q" $uma.Variant }}
{{- end }}
x -> "uma " ++ x.show
// Get the character ID for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun character-id(uma: uma-id): character-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Character-id({{ $uma.CharacterID }})
{{- end }}
_ -> Character-id(0)
// Get the sprint aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun sprint(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Sprint }}
{{- end }}
_ -> G
// Get the mile aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun mile(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Mile }}
{{- end }}
_ -> G
// Get the medium aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun medium(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Medium }}
{{- end }}
_ -> G
// Get the long aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun long(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Long }}
{{- end }}
_ -> G
// Get the front runner aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun front-runner(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Front }}
{{- end }}
_ -> G
// Get the pace chaser aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun pace-chaser(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Pace }}
{{- end }}
_ -> G
// Get the late surger aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun late-surger(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Late }}
{{- end }}
_ -> G
// Get the end closer aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun end-closer(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.End }}
{{- end }}
_ -> G
// Get the turf aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun turf(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Turf }}
{{- end }}
_ -> G
// Get the dirt aptitude for an Uma.
// If no Uma matches the ID, the result is G.
pub fun dirt(uma: uma-id): aptitude-level
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> {{ template "koka-aptitude-level" $uma.Dirt }}
{{- end }}
_ -> G
// Get the unique skill for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun unique(uma: uma-id): skill-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Skill-id({{ $uma.UniqueID }})
{{- end }}
_ -> Skill-id(0)
// Get the first built-in skill for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun skill1(uma: uma-id): skill-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Skill-id({{ $uma.Skill1 }})
{{- end }}
_ -> Skill-id(0)
// Get the second built-in skill for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun skill2(uma: uma-id): skill-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Skill-id({{ $uma.Skill2 }})
{{- end }}
_ -> Skill-id(0)
// Get the third built-in skill for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun skill3(uma: uma-id): skill-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Skill-id({{ $uma.Skill3 }})
{{- end }}
_ -> Skill-id(0)
// Get the potential level 2 skill for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun skill-pl2(uma: uma-id): skill-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Skill-id({{ $uma.SkillPL2 }})
{{- end }}
_ -> Skill-id(0)
// Get the potential level 3 skill for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun skill-pl3(uma: uma-id): skill-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Skill-id({{ $uma.SkillPL3 }})
{{- end }}
_ -> Skill-id(0)
// Get the potential level 4 skill for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun skill-pl4(uma: uma-id): skill-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Skill-id({{ $uma.SkillPL4 }})
{{- end }}
_ -> Skill-id(0)
// Get the potential level 5 skill for an Uma.
// If no Uma matches the ID, the result is an invalid ID.
pub fun skill-pl5(uma: uma-id): skill-id
match uma.game-id
{{- range $uma := $.Umas }}
{{ $uma.ID }} -> Skill-id({{ $uma.SkillPL5 }})
{{- end }}
_ -> Skill-id(0)
{{ end }}
{{- define "koka-aptitude-level" -}}
{{- if eq . 1 -}} G
{{- else if eq . 2 -}} F
{{- else if eq . 3 -}} E
{{- else if eq . 4 -}} D
{{- else if eq . 5 -}} C
{{- else if eq . 6 -}} B
{{- else if eq . 7 -}} A
{{- else if eq . 8 -}} S
{{- else -}} ??? aptitude={{ . }}
{{- end -}}
{{- end -}}