horsegen: generate inherited skills
This commit is contained in:
@@ -53,32 +53,33 @@ module horse/skill
|
||||
import std/num/float64
|
||||
pub import horse/skill-group
|
||||
|
||||
// Skills instances.
|
||||
// Skill instances.
|
||||
pub type skill
|
||||
{{- range $s := $.Skills }}
|
||||
{{ kkenum $s.Name }}
|
||||
{{ kkenum $s.Name }}{{ if ne $s.InheritID 0 }}-Inherit{{ end -}}
|
||||
{{- end }}
|
||||
|
||||
// Map a skill to its ID.
|
||||
pub fip fun skill/skill-id(^s: skill): int
|
||||
match s
|
||||
{{- range $s := $.Skills }}
|
||||
{{ kkenum $s.Name }} -> {{ $s.ID }}
|
||||
{{ kkenum $s.Name }}{{ if ne $s.InheritID 0 }}-Inherit{{ end }} -> {{ $s.ID }}
|
||||
{{- end }}
|
||||
|
||||
// Get the skill for an ID.
|
||||
pub fip(1) fun skill/from-id(^id: int): maybe<skill>
|
||||
match id
|
||||
{{- range $s := $.Skills }}
|
||||
{{ $s.ID }} -> Just( {{- kkenum $s.Name -}} )
|
||||
{{ $s.ID }} -> Just( {{- kkenum $s.Name -}}{{ if ne $s.InheritID 0 }}-Inherit{{ end -}} )
|
||||
{{- end }}
|
||||
_ -> Nothing
|
||||
|
||||
// Get the name of a skill.
|
||||
// Inherited skills have the same names as their original counterparts.
|
||||
pub fun skill/show(s: skill): string
|
||||
match s
|
||||
{{- range $s := $.Skills }}
|
||||
{{ kkenum $s.Name }} -> {{ printf "%q" $s.Name }}
|
||||
{{ kkenum $s.Name }}{{ if ne $s.InheritID 0 }}-Inherit{{ end }} -> {{ printf "%q" $s.Name }}
|
||||
{{- end }}
|
||||
|
||||
// Compare two skills by ID order.
|
||||
@@ -95,7 +96,7 @@ pub fun skill/(==)(a: skill, b: skill): bool
|
||||
pub fun skill/detail(^s: skill): skill-detail
|
||||
match s
|
||||
{{- range $s := $.Skills }}
|
||||
{{ kkenum $s.Name }} -> {{ template "kk-render-skill-detail" $s }}
|
||||
{{ kkenum $s.Name }}{{ if ne $s.InheritID 0 }}-Inherit{{ end }} -> {{ template "kk-render-skill-detail" $s }}
|
||||
{{- end }}
|
||||
|
||||
// Details about a skill.
|
||||
@@ -103,7 +104,7 @@ pub struct skill-detail
|
||||
skill-id: int
|
||||
name: string
|
||||
description: string
|
||||
group: skill-group
|
||||
group: maybe<skill-group>
|
||||
rarity: rarity
|
||||
group-rate: int
|
||||
grade-value: int
|
||||
@@ -175,7 +176,7 @@ pub type ability-type
|
||||
Passive-Power(bonus: float64)
|
||||
Passive-Guts(bonus: float64)
|
||||
Passive-Wit(bonus: float64)
|
||||
Runaway
|
||||
Great-Escape
|
||||
Vision(bonus: float64)
|
||||
HP(rate: float64)
|
||||
Gate-Delay(rate: float64)
|
||||
@@ -193,7 +194,7 @@ pub fun ability-type/show(a: ability-type): string
|
||||
Passive-Power(bonus) -> "passive " ++ bonus.show ++ " Power"
|
||||
Passive-Guts(bonus) -> "passive " ++ bonus.show ++ " Guts"
|
||||
Passive-Wit(bonus) -> "passive " ++ bonus.show ++ " Wit"
|
||||
Runaway -> "enable Great Escape style"
|
||||
Great-Escape -> "enable Great Escape style"
|
||||
Vision(bonus) -> bonus.show ++ " vision"
|
||||
HP(rate) | rate >= 0.0 -> show(rate * 100.0) ++ "% HP recovery"
|
||||
HP(rate) -> show(rate * 100.0) ++ "% HP loss"
|
||||
@@ -223,7 +224,7 @@ pub fun value-usage/show(v: value-usage): string
|
||||
Team-Power -> "team's Power"
|
||||
Team-Guts -> "team's Guts"
|
||||
Team-Wit -> "team's Wit"
|
||||
Multiply-Random -> "random multiplier (0× to 0.04×)"
|
||||
Multiply-Random -> "random multiplier (0×, 0.02×, or 0.04×)"
|
||||
|
||||
// Who a skill activation targets.
|
||||
pub type target
|
||||
@@ -258,7 +259,7 @@ pub fun target/show(t: target): string
|
||||
Rushing-Style(End-Closer) -> "rushing End Closers"
|
||||
|
||||
// Running style for skill targets.
|
||||
// TODO(zeph): there is definitely a better place for this to live
|
||||
{{- /* TODO(zeph): there is definitely a better place for this to live */}}
|
||||
pub type style
|
||||
Front-Runner
|
||||
Pace-Chaser
|
||||
@@ -272,7 +273,7 @@ pub type style
|
||||
Skill-detail(skill-id = {{ $.ID -}}
|
||||
, name = {{ printf "%q" $.Name -}}
|
||||
, description = {{ printf "%q" $.Description -}}
|
||||
, group = {{ kkenum $.GroupName -}}
|
||||
, group = {{ if ne $.GroupName "" }}Just({{ kkenum $.GroupName }}){{ else }}Nothing{{ end -}}
|
||||
, rarity = {{ if eq $.Rarity 1 }}Common{{ else if eq $.Rarity 2 }}Rare{{ else if eq $.Rarity 3 }}Unique-Low{{ else if eq $.Rarity 4 }}Unique-Upgraded{{ else if eq $.Rarity 5 }}Unique{{ else }}??? $.Rarity={{ $.Rarity }}{{ end -}}
|
||||
, group-rate = {{ $.GroupRate -}}
|
||||
, grade-value = {{ $.GradeValue -}}
|
||||
@@ -293,7 +294,7 @@ Skill-detail(skill-id = {{ $.ID -}}
|
||||
{{- else if eq $abil.Type 3 -}}Passive-Power({{ printf "%f" $abil.Value }})
|
||||
{{- else if eq $abil.Type 4 -}}Passive-Guts({{ printf "%f" $abil.Value }})
|
||||
{{- else if eq $abil.Type 5 -}}Passive-Wit({{ printf "%f" $abil.Value }})
|
||||
{{- else if eq $abil.Type 6 -}}Runaway
|
||||
{{- else if eq $abil.Type 6 -}}Great-Escape
|
||||
{{- else if eq $abil.Type 8 -}}Vision({{ printf "%f" $abil.Value }})
|
||||
{{- else if eq $abil.Type 9 -}}HP({{ printf "%f" $abil.Value }})
|
||||
{{- else if eq $abil.Type 10 -}}Gate-Delay({{ printf "%f" $abil.Value }})
|
||||
@@ -332,6 +333,6 @@ Skill-detail(skill-id = {{ $.ID -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
], sp-cost = {{ $.SPCost -}}
|
||||
,icon-id = {{ $.IconID -}}
|
||||
, icon-id = {{ $.IconID -}}
|
||||
)
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user