{{- define "koka-spark" -}} module horse/{{ $.Region }}/spark // Automatically generated with horsegen; DO NOT EDIT import horse/game-id pub import horse/spark // Enumeration of all sparks for type-safe programming. pub type spark {{- range $s := $.Sparks }} {{ kkenum $s.Name }}-Lv{{ $s.Rarity }} {{- end }} // Get the ID for a spark. pub fun spark-id(s: spark): spark-id match s {{- range $s := $.Sparks }} {{ kkenum $s.Name }}-Lv{{ $s.Rarity }} -> Spark-id({{ $s.ID }}) {{- end }} // List of all sparks in ID order for easy iterating. pub val all = [ {{- range $s := $.Sparks }} {{ kkenum $s.Name }}-Lv{{ $s.Rarity }}, {{- end }} ] // 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> 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 }}