horsegen: generate scenarios since sparks use them
This commit is contained in:
45
horsegen/scenario.kk.template
Normal file
45
horsegen/scenario.kk.template
Normal file
@@ -0,0 +1,45 @@
|
||||
{{- define "koka-scenario" -}}
|
||||
module horse/{{ $.Region }}/scenario
|
||||
|
||||
// Automatically generated with horsegen; DO NOT EDIT
|
||||
|
||||
import horse/game-id
|
||||
|
||||
// Enumeration of all scenarios for type-safe programming.
|
||||
pub type scenario
|
||||
{{- range $s := $.Scenarios }}
|
||||
{{ kkenum $s.Name }}
|
||||
{{- end }}
|
||||
|
||||
// Get the scenario ID for a scenario.
|
||||
pub fun scenario-id(s: scenario): scenario-id
|
||||
match s
|
||||
{{- range $s := $.Scenarios }}
|
||||
{{ kkenum $s.Name }} -> Scenario-id({{ $s.ID }})
|
||||
{{- end }}
|
||||
|
||||
// List of all scenarios in ID order for easy iterating.
|
||||
pub val all = [
|
||||
{{- range $s := $.Scenarios }}
|
||||
{{ kkenum $s.Name }},
|
||||
{{- end }}
|
||||
]
|
||||
|
||||
// Get the name for a scenario.
|
||||
// If no scenario matches the ID, the result contains the numeric ID.
|
||||
pub fun show(s: scenario-id): string
|
||||
match s.game-id
|
||||
{{- range $s := $.Scenarios }}
|
||||
{{ $s.ID }} -> {{ printf "%q" $s.Name }}
|
||||
{{- end }}
|
||||
x -> "scenario " ++ x.show
|
||||
|
||||
// Get the full title for a scenario, e.g. "The Beginning: URA Finale".
|
||||
// If no scenario matches the ID, the result contains the numeric ID.
|
||||
pub fun title(s: scenario-id): string
|
||||
match s.game-id
|
||||
{{- range $s := $.Scenarios }}
|
||||
{{ $s.ID }} -> {{ printf "%q" $s.Title }}
|
||||
{{- end }}
|
||||
x -> "scenario " ++ x.show
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user