horsegen: use decimal instead of float64 for skill rates

This commit is contained in:
2026-01-11 09:01:15 -05:00
parent fae0fa7699
commit 399f160718
4 changed files with 585 additions and 585 deletions

View File

@@ -50,7 +50,7 @@ pub fun skill-group/(==)(a: skill-group, b: skill-group): bool
{{- define "koka-skill" -}}
module horse/skill
import std/num/float64
import std/num/decimal
pub import horse/skill-group
// Skill instances.
@@ -131,9 +131,9 @@ pub fun rarity/show(r: rarity): string
match r
Common -> "Common"
Rare -> "Rare"
Unique-Low -> "Unique (1☆/2☆)"
Unique-Upgraded -> "Unique (3+ from 1☆/2☆ upgraded)"
Unique -> "Unique (3+)"
Unique-Low -> "Unique (1\u2606/2\u2606)"
Unique-Upgraded -> "Unique (3\u2606+ from 1\u2606/2\u2606 upgraded)"
Unique -> "Unique (3\u2606+)"
// Condition and precondition logic.
pub alias condition = string
@@ -143,17 +143,17 @@ pub alias condition = string
pub struct activation
precondition: condition
condition: condition
duration: float64 // seconds
cooldown: float64 // seconds
duration: decimal // seconds
cooldown: decimal // seconds
abilities: list<ability> // one to three elements
pub fun activation/show(a: activation): string
match a
Activation("", condition, -1.0, _, abilities) -> condition ++ " -> " ++ abilities.show
Activation("", condition, duration, cooldown, abilities) | cooldown >= 500.0 -> condition ++ " -> " ++ abilities.show ++ " for " ++ duration.show ++ "s"
Activation("", condition, duration, _, abilities) | duration <= 0.decimal -> condition ++ " -> " ++ abilities.show
Activation("", condition, duration, cooldown, abilities) | cooldown >= 500.decimal -> condition ++ " -> " ++ abilities.show ++ " for " ++ duration.show ++ "s"
Activation("", condition, duration, cooldown, abilities) -> condition ++ " -> " ++ abilities.show ++ " for " ++ duration.show ++ "s on " ++ cooldown.show ++ "s cooldown"
Activation(precondition, condition, -1.0, _, abilities)-> precondition ++ " -> " ++ condition ++ " -> " ++ abilities.show
Activation(precondition, condition, duration, cooldown, abilities) | cooldown >= 500.0 -> precondition ++ " -> " ++ condition ++ " -> " ++ abilities.show ++ " for " ++ duration.show ++ "s"
Activation(precondition, condition, duration, _, abilities) | duration <= 0.decimal -> precondition ++ " -> " ++ condition ++ " -> " ++ abilities.show
Activation(precondition, condition, duration, cooldown, abilities) | cooldown >= 500.decimal -> precondition ++ " -> " ++ condition ++ " -> " ++ abilities.show ++ " for " ++ duration.show ++ "s"
Activation(precondition, condition, duration, cooldown, abilities) -> precondition ++ "-> " ++ condition ++ " -> " ++ abilities.show ++ " for " ++ duration.show ++ "s on " ++ cooldown.show ++ "s cooldown"
// Effects of activating a skill.
@@ -171,21 +171,21 @@ pub fun ability/show(a: ability): string
// Target of a skill activation effect.
pub type ability-type
Passive-Speed(bonus: float64)
Passive-Stamina(bonus: float64)
Passive-Power(bonus: float64)
Passive-Guts(bonus: float64)
Passive-Wit(bonus: float64)
Passive-Speed(bonus: decimal)
Passive-Stamina(bonus: decimal)
Passive-Power(bonus: decimal)
Passive-Guts(bonus: decimal)
Passive-Wit(bonus: decimal)
Great-Escape
Vision(bonus: float64)
HP(rate: float64)
Gate-Delay(rate: float64)
Frenzy(add: float64)
Current-Speed(rate: float64)
Target-Speed(rate: float64)
Lane-Speed(rate: float64)
Accel(rate: float64)
Lane-Change(rate: float64)
Vision(bonus: decimal)
HP(rate: decimal)
Gate-Delay(rate: decimal)
Frenzy(add: decimal)
Current-Speed(rate: decimal)
Target-Speed(rate: decimal)
Lane-Speed(rate: decimal)
Accel(rate: decimal)
Lane-Change(rate: decimal)
pub fun ability-type/show(a: ability-type): string
match a
@@ -196,14 +196,14 @@ pub fun ability-type/show(a: ability-type): string
Passive-Wit(bonus) -> "passive " ++ bonus.show ++ " Wit"
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"
HP(rate) | rate >= 0.decimal -> show(rate * 100.decimal) ++ "% HP recovery"
HP(rate) -> show(rate * 100.decimal) ++ "% HP loss"
Gate-Delay(rate) -> rate.show ++ "× gate delay"
Frenzy(add) -> add.show ++ "s longer Rushed"
Current-Speed(rate) -> show(rate * 100.0) ++ "% current speed"
Target-Speed(rate) -> show(rate * 100.0) ++ "% target speed"
Lane-Speed(rate) -> show(rate * 100.0) ++ "% lane speed"
Accel(rate) -> show(rate * 100.0) ++ "% acceleration"
Current-Speed(rate) -> show(rate * 100.decimal) ++ "% current speed"
Target-Speed(rate) -> show(rate * 100.decimal) ++ "% target speed"
Lane-Speed(rate) -> show(rate * 100.decimal) ++ "% lane speed"
Accel(rate) -> show(rate * 100.decimal) ++ "% acceleration"
Lane-Change(rate) -> rate.show ++ " course width movement"
// Special scaling for skill activation effects.
@@ -283,27 +283,27 @@ Skill-detail(skill-id = {{ $.ID -}}
{{- if ne $a.Condition "" -}}
Activation(precondition = {{ printf "%q" $a.Precondition -}}
, condition = {{ printf "%q" $a.Condition -}}
, duration = {{ printf "%f" $a.Duration -}}
, cooldown = {{ printf "%f" $a.Cooldown -}}
, duration = {{ $a.Duration -}}{{ if gt $a.Duration 0 }}.decimal(-4){{ else }}.decimal{{ end -}}
, cooldown = {{ $a.Cooldown -}}{{ if gt $a.Cooldown 0 }}.decimal(-4){{ else }}.decimal{{ end -}}
, abilities = [
{{- range $abil := $a.Abilities -}}
{{- if ne $abil.Type 0 -}}
Ability(ability-type =
{{- if eq $abil.Type 1 -}}Passive-Speed({{ printf "%f" $abil.Value }})
{{- else if eq $abil.Type 2 -}}Passive-Stamina({{ printf "%f" $abil.Value }})
{{- 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 }})
{{- if eq $abil.Type 1 -}}Passive-Speed({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 2 -}}Passive-Stamina({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 3 -}}Passive-Power({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 4 -}}Passive-Guts({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 5 -}}Passive-Wit({{ $abil.Value }}.decimal(-4))
{{- 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 }})
{{- else if eq $abil.Type 13 -}}Frenzy({{ printf "%f" $abil.Value }})
{{- else if eq $abil.Type 21 -}}Current-Speed({{ printf "%f" $abil.Value }})
{{- else if eq $abil.Type 27 -}}Target-Speed({{ printf "%f" $abil.Value }})
{{- else if eq $abil.Type 28 -}}Lane-Speed({{ printf "%f" $abil.Value }})
{{- else if eq $abil.Type 31 -}}Accel({{ printf "%f" $abil.Value }})
{{- else if eq $abil.Type 35 -}}Lane-Change({{ printf "%f" $abil.Value }})
{{- else if eq $abil.Type 8 -}}Vision({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 9 -}}HP({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 10 -}}Gate-Delay({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 13 -}}Frenzy({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 21 -}}Current-Speed({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 27 -}}Target-Speed({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 28 -}}Lane-Speed({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 31 -}}Accel({{ $abil.Value }}.decimal(-4))
{{- else if eq $abil.Type 35 -}}Lane-Change({{ $abil.Value }}.decimal(-4))
{{- else -}}??? $abil.Type={{$abil.Type}}
{{- end -}}
, value-usage =