59 lines
2.1 KiB
Plaintext
59 lines
2.1 KiB
Plaintext
{{- define "koka-saddle" -}}
|
|
module horse/{{ $.Region }}/saddle
|
|
|
|
// Automatically generated with horsegen; DO NOT EDIT
|
|
|
|
import std/core/delayed
|
|
import std/core/vector
|
|
import std/core-extras
|
|
import horse/game-id
|
|
pub import horse/race
|
|
pub import horse/{{ $.Region }}/race
|
|
|
|
extern create-id-table(): vector<int>
|
|
c inline "int32_t arr[] = { {{- range $s := $.Saddles }}{{ $s.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.SaddleCount }}, kk_context())"
|
|
js inline "[{{ range $s := $.Saddles }}{{ $s.ID }},{{ end }}]"
|
|
// Vector of all saddle IDs in order for easy iterating.
|
|
val all = once(create-id-table)
|
|
|
|
// Get the name for a saddle.
|
|
// Alternate versions of saddles have an indication of their ID in their names.
|
|
// If no saddle matches the ID, the result contains the numeric ID.
|
|
pub fun show(s: saddle-id): string
|
|
match s.game-id
|
|
{{- range $s := $.Saddles }}
|
|
{{ $s.ID }} -> {{ printf "%q" $s.Name }}{{ if $s.Alternate }} ++ " (Alternate {{ $s.ID }})"{{ end }}
|
|
{{- end }}
|
|
x -> "saddle " ++ x.show
|
|
|
|
// Get the list of races that entitle a horse to a saddle.
|
|
// If no saddle matches the ID, the result is the empty list.
|
|
pub fun races(s: saddle-id): list<race-id>
|
|
match s.game-id
|
|
{{- range $s := $.Saddles }}
|
|
{{ $s.ID }} -> [{{ range $id := $s.Races }}{{ if $id }}Race-id({{ $id }}), {{ end }}{{ end }}]
|
|
{{- end }}
|
|
_ -> []
|
|
|
|
// Get a saddle's type.
|
|
// If no saddle matches the ID, the result is Honor.
|
|
pub fun saddle-type(s: saddle-id): saddle-type
|
|
match s.game-id
|
|
{{- range $s := $.Saddles }}
|
|
{{ $s.ID }} -> {{ if eq $s.Type 0 }}Honor{{ else if eq $s.Type 1 }}G3-Win{{ else if eq $s.Type 2 }}G2-Win{{ else if eq $s.Type 3 }}G1-Win{{ else }}??? $s.Type={{ $s.Type }}{{ end }}
|
|
{{- end }}
|
|
_ -> Honor
|
|
|
|
// Get the primary ID for a saddle.
|
|
// For saddles which are the primary version, or if no saddle matches the given ID,
|
|
// the result is the input.
|
|
pub fun primary(s: saddle-id): saddle-id
|
|
match s.game-id
|
|
{{- range $s := $.Saddles }}
|
|
{{- if $s.Alternate }}
|
|
{{ $s.ID }} -> Saddle-id({{ $s.Primary }})
|
|
{{- end }}
|
|
{{- end }}
|
|
_ -> s
|
|
{{ end }}
|