122 lines
5.0 KiB
Plaintext
122 lines
5.0 KiB
Plaintext
{{- define "koka-spark" -}}
|
|
module horse/{{ $.Region }}/spark
|
|
|
|
// 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/spark
|
|
|
|
extern create-id-table(): vector<int>
|
|
c inline "int32_t arr[] = { {{- range $s := $.Sparks }}{{ $s.ID }},{{ end -}} };\nkk_vector_from_cint32array(arr, (kk_ssize_t){{ $.SparkCount }}, kk_context())"
|
|
js inline "[{{ range $s := $.Sparks }}{{ $s.ID }},{{ end }}]"
|
|
// Vector of all spark IDs in order for easy iterating.
|
|
val all = once(create-id-table)
|
|
|
|
// Get the name for a spark.
|
|
// The name does not indicate the spark level.
|
|
// If no spark matches the ID, the result contains the numeric ID.
|
|
pub fun show(s: spark-id): string
|
|
match s.game-id
|
|
{{- range $s := $.Sparks }}
|
|
{{ $s.ID }} -> {{ printf "%q" $s.Name }}
|
|
{{- end }}
|
|
x -> "spark " ++ x.show
|
|
|
|
// Get the description for a spark.
|
|
// The description does not indicate the spark level.
|
|
// If no spark matches the ID, the result contains the numeric ID.
|
|
pub fun description(s: spark-id): string
|
|
match s.game-id
|
|
{{- range $s := $.Sparks }}
|
|
{{ $s.ID }} -> {{ printf "%q" $s.Description }}
|
|
{{- end }}
|
|
x -> "spark " ++ x.show
|
|
|
|
// Get the spark group ID of a spark.
|
|
// If no spark matches the ID, the result is an invalid ID.
|
|
pub fun spark-group(s: spark-id): spark-group-id
|
|
match s.game-id
|
|
{{- range $s := $.Sparks }}
|
|
{{ $s.ID }} -> Spark-group-id({{ $s.Group }})
|
|
{{- end }}
|
|
_ -> Spark-group-id(0)
|
|
|
|
// Get the rarity (level or star count) of a spark.
|
|
// If no spark matches the ID, the result is One.
|
|
pub fun rarity(s: spark-id): rarity
|
|
match s.game-id
|
|
{{- range $s := $.Sparks }}
|
|
{{ $s.ID }} -> {{ if eq $s.Rarity 1 }}One{{ else if eq $s.Rarity 2 }}Two{{ else if eq $s.Rarity 3 }}Three{{ else }}??? $s.Rarity={{ $s.Rarity }}{{ end }}
|
|
{{- end }}
|
|
_ -> One
|
|
|
|
// Get the type of a spark.
|
|
// If no spark matches the ID, the result is Stat.
|
|
pub fun spark-type(s: spark-id): spark-type
|
|
match s.game-id
|
|
{{- range $s := $.Sparks }}
|
|
{{ $s.ID }} -> {{ if eq $s.Type 1 }}Stat
|
|
{{- else if eq $s.Type 2 }}Aptitude
|
|
{{- else if eq $s.Type 5 }}Race
|
|
{{- else if eq $s.Type 4 }}Skill
|
|
{{- else if eq $s.Type 6 }}Scenario
|
|
{{- else if eq $s.Type 7 }}Carnival-Bonus
|
|
{{- else if eq $s.Type 10 }}Surface
|
|
{{- else if eq $s.Type 8 }}Distance
|
|
{{- else if eq $s.Type 11 }}Style
|
|
{{- else if eq $s.Type 9 }}Hidden
|
|
{{- else if eq $s.Type 3 }}Unique
|
|
{{- else }}??? $s.Type={{ $s.Type }}
|
|
{{- end }}
|
|
{{- end }}
|
|
_ -> Stat
|
|
|
|
// Get the list of all effects a spark can apply during inheritance.
|
|
// When a spark procs, a random element is chosen from the list yielded by this
|
|
// function according to a hidden distribution, then all effects in that are applied.
|
|
// If no spark matches the ID, the result is the empty list.
|
|
pub fun effects(s: spark-id): list<list<spark-effect>>
|
|
match s.game-id
|
|
{{- range $s := $.Sparks }}
|
|
{{ $s.ID }} -> [
|
|
{{- range $r := index $.SparkEffects $s.Group }}
|
|
[
|
|
{{- range $e := $r -}}
|
|
{{- if eq $e.Target 1 -}}Stat-Up(Speed, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 2 -}}Stat-Up(Stamina, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 3 -}}Stat-Up(Power, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 4 -}}Stat-Up(Guts, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 5 -}}Stat-Up(Wit, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 6 -}}SP-Up({{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 7 -}}Random-Stat-Up({{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 11 -}}Aptitude-Up(Turf, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 12 -}}Aptitude-Up(Dirt, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 21 -}}Aptitude-Up(Front-Runner, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 22 -}}Aptitude-Up(Pace-Chaser, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 23 -}}Aptitude-Up(Late-Surger, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 24 -}}Aptitude-Up(End-Closer, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 31 -}}Aptitude-Up(Sprint, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 32 -}}Aptitude-Up(Mile, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 33 -}}Aptitude-Up(Medium, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 34 -}}Aptitude-Up(Long, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 41 -}}Skill-Hint(Skill-id({{ $e.Value1 }}), {{ $e.Value2 }}),
|
|
{{- else if eq $e.Target 51 -}}Carnival-Bonus {{/*- skipped, but doesn't hurt to put it here -*/}}
|
|
{{- else if eq $e.Target 61 -}}Stat-Cap-Up(Speed, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 62 -}}Stat-Cap-Up(Stamina, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 63 -}}Stat-Cap-Up(Power, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 64 -}}Stat-Cap-Up(Guts, {{ $e.Value1 }}),
|
|
{{- else if eq $e.Target 65 -}}Stat-Cap-Up(Wit, {{ $e.Value1 }}),
|
|
{{- else -}}
|
|
??? $e.Target={{- $e.Target -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
],
|
|
{{- end }}
|
|
]
|
|
{{- end }}
|
|
_ -> []
|
|
{{ end }}
|