70 lines
2.3 KiB
Plaintext
70 lines
2.3 KiB
Plaintext
{{- define "koka-saddle" -}}
|
|
module horse/{{ $.Region }}/saddle
|
|
|
|
// Automatically generated with horsegen; DO NOT EDIT
|
|
|
|
import horse/game-id
|
|
pub import horse/race
|
|
pub import horse/{{ $.Region }}/race
|
|
|
|
// Enumeration of all saddles for type-safe programming.
|
|
pub type saddle
|
|
{{- range $s := $.Saddles }}
|
|
{{ kkenum $s.Name }}{{ if $s.Alternate }}-Alt{{ $s.ID }}{{ end }}
|
|
{{- end }}
|
|
|
|
// Get the saddle ID for a saddle.
|
|
pub fun saddle-id(s: saddle): saddle-id
|
|
match s
|
|
{{- range $s := $.Saddles }}
|
|
{{ kkenum $s.Name }}{{ if $s.Alternate }}-Alt{{ $s.ID }}{{ end }} -> Saddle-id({{ $s.ID }})
|
|
{{- end }}
|
|
|
|
// List of all saddles in ID order for easy iterating.
|
|
pub val all = [
|
|
{{- range $s := $.Saddles }}
|
|
{{ kkenum $s.Name }}{{ if $s.Alternate }}-Alt{{ $s.ID }}{{ end }},
|
|
{{- end }}
|
|
]
|
|
|
|
// 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 }}
|