horsegen: generate data per region

This commit is contained in:
2026-01-15 13:43:54 -05:00
parent 5b5e008b5e
commit d6fb4b6caf
16 changed files with 1287 additions and 2261 deletions

66
go/abilitytype_string.go Normal file
View File

@@ -0,0 +1,66 @@
// Code generated by "stringer -type AbilityType -trimprefix Ability"; DO NOT EDIT.
package horse
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[AbilityPassiveSpeed-1]
_ = x[AbilityPassiveStamina-2]
_ = x[AbilityPassivePower-3]
_ = x[AbilityPassiveGuts-4]
_ = x[AbilityPassiveWit-5]
_ = x[AbilityGreatEscape-6]
_ = x[AbilityVision-8]
_ = x[AbilityHP-9]
_ = x[AbilityGateDelay-10]
_ = x[AbilityFrenzy-13]
_ = x[AbilityCurrentSpeed-21]
_ = x[AbilityTargetSpeed-27]
_ = x[AbilityLaneSpeed-28]
_ = x[AbilityAccel-31]
_ = x[AbilityLaneChange-35]
}
const (
_AbilityType_name_0 = "PassiveSpeedPassiveStaminaPassivePowerPassiveGutsPassiveWitGreatEscape"
_AbilityType_name_1 = "VisionHPGateDelay"
_AbilityType_name_2 = "Frenzy"
_AbilityType_name_3 = "CurrentSpeed"
_AbilityType_name_4 = "TargetSpeedLaneSpeed"
_AbilityType_name_5 = "Accel"
_AbilityType_name_6 = "LaneChange"
)
var (
_AbilityType_index_0 = [...]uint8{0, 12, 26, 38, 49, 59, 70}
_AbilityType_index_1 = [...]uint8{0, 6, 8, 17}
_AbilityType_index_4 = [...]uint8{0, 11, 20}
)
func (i AbilityType) String() string {
switch {
case 1 <= i && i <= 6:
i -= 1
return _AbilityType_name_0[_AbilityType_index_0[i]:_AbilityType_index_0[i+1]]
case 8 <= i && i <= 10:
i -= 8
return _AbilityType_name_1[_AbilityType_index_1[i]:_AbilityType_index_1[i+1]]
case i == 13:
return _AbilityType_name_2
case i == 21:
return _AbilityType_name_3
case 27 <= i && i <= 28:
i -= 27
return _AbilityType_name_4[_AbilityType_index_4[i]:_AbilityType_index_4[i+1]]
case i == 31:
return _AbilityType_name_5
case i == 35:
return _AbilityType_name_6
default:
return "AbilityType(" + strconv.FormatInt(int64(i), 10) + ")"
}
}

264
go/global/character.go Normal file

File diff suppressed because one or more lines are too long

12281
go/global/skill.go Normal file

File diff suppressed because it is too large Load Diff

72
go/skill.go Normal file
View File

@@ -0,0 +1,72 @@
package horse
import "strconv"
type SkillID int32
type TenThousandths int32
func (x TenThousandths) String() string {
b := make([]byte, 0, 12)
b = strconv.AppendInt(b, int64(x/1e4), 10)
b = append(b, '.')
if x < 0 {
x = -x
}
b = strconv.AppendInt(b, int64(x%1e4), 10)
return string(b)
}
// Skill is the internal data about a skill.
type Skill struct {
ID SkillID
Name string
Description string
Group int32
Rarity int8
GroupRate int8
GradeValue int32
WitCheck bool
Activations []Activation
SPCost int
IconID int
}
// Activation is the parameters controlling when a skill activates.
type Activation struct {
Precondition string
Condition string
Duration TenThousandths
Cooldown TenThousandths
Abilities []Ability
}
// Ability is an individual effect applied by a skill.
type Ability struct {
Type AbilityType
ValueUsage int8
Value int32
Target int8
TargetValue int32
}
type AbilityType int8
//go:generate go run golang.org/x/tools/cmd/stringer@v0.41.0 -type AbilityType -trimprefix Ability
const (
AbilityPassiveSpeed AbilityType = 1
AbilityPassiveStamina AbilityType = 2
AbilityPassivePower AbilityType = 3
AbilityPassiveGuts AbilityType = 4
AbilityPassiveWit AbilityType = 5
AbilityGreatEscape AbilityType = 6
AbilityVision AbilityType = 8
AbilityHP AbilityType = 9
AbilityGateDelay AbilityType = 10
AbilityFrenzy AbilityType = 13
AbilityCurrentSpeed AbilityType = 21
AbilityTargetSpeed AbilityType = 27
AbilityLaneSpeed AbilityType = 28
AbilityAccel AbilityType = 31
AbilityLaneChange AbilityType = 35
)

36
go/skill_test.go Normal file
View File

@@ -0,0 +1,36 @@
package horse_test
import (
"cmp"
"slices"
"strings"
"sync"
"testing"
horse "git.sunturtle.xyz/zephyr/horse/go"
"git.sunturtle.xyz/zephyr/horse/go/global"
)
var SortedSkills = sync.OnceValue(func() []horse.Skill {
skills := make([]horse.Skill, 0, len(global.AllSkills))
for _, v := range global.AllSkills {
skills = append(skills, v)
}
slices.SortFunc(skills, func(a, b horse.Skill) int { return cmp.Compare(a.ID, b.ID) })
return skills
})
func TestSkillStrings(t *testing.T) {
t.Parallel()
for _, s := range SortedSkills() {
// We could check that s.ID.String() matches s.Name,
// but that may be awkward for inherited skills.
for _, a := range s.Activations {
for _, abil := range a.Abilities {
if n := abil.Type.String(); strings.HasPrefix(n, "AbilityType(") {
t.Errorf("%v %s: %s", s.ID, s.Name, n)
}
}
}
}
}