Compare commits

...

4 Commits

22 changed files with 26189 additions and 141 deletions

View File

@@ -12,6 +12,7 @@ This file is my notes from exploring the database.
- 147 is spark names, 172 is spark descriptions
- 33 is race names by race id, 28 is race names by race instance id, 31 is race courses, 111 is saddle names
- 65 is player titles, 66 is title descriptions - ties with honor_data?
- 119 is scenario full titles (e.g. The Beginning: URA Finale), 120 is scenario descriptions, 237 is scenario names (e.g. URA Finale)
# succession factor (sparks)
@@ -23,6 +24,11 @@ factor_type:
- 5 race
- 4 skill
- 6 scenario
- 7 carnival bonus
- 10 surface gene (white, on jp)
- 8 distance gene (white)
- 11 style gene (white)
- 9 hidden (white, for things like many wins in west japan, summer sprint series, &c.)
- 3 unique
target_type:
@@ -31,6 +37,8 @@ target_type:
- 3 power
- 4 guts
- 5 wit
- 6 skill points
- 7 random stat; value 1 is amount, value 2 is always 1?
- 11 turf; value 1 is number of levels (1 or 2), value 2 is 0
- 12 dirt
- 21 front
@@ -41,7 +49,15 @@ target_type:
- 32 mile
- 33 medium
- 34 long
- 41 is skill; value 1 is skill id, value 2 is hint level (1-5)
- 41 skill; value 1 is skill id, value 2 is hint level (1-5)
- 51 carnival bonus; value 1 is skill id, value 2 is 1
- 61 speed cap; value 1 is presumably amount but the numbers are very small, 1-4; value 2 is 0
- 62 stam cap
- 63 power cap
- 64 guts cap
- 65 wit cap
grade is 2 for unique sparks and 1 otherwise.
every possible result has a row in succession_factor_effect.
effect_id distinguishes possibilities; factors with multiple effects (race and scenario sparks) have multiple rows with equal effect_id.

View File

@@ -2,11 +2,14 @@ module horse/game-id
// Game ID for characters, cards, skills, races, &c.
// Values for different categories may overlap.
alias game-id = int
pub alias game-id = int
// Specific game ID types.
// I've already made mistakes with ID categories and I haven't even committed this file yet.
pub struct scenario-id
game-id: game-id
// Game ID for characters.
// Generally numbers in the range 1000-9999.
pub struct character-id
@@ -43,6 +46,16 @@ pub struct race-thumbnail-id
pub struct saddle-id
game-id: game-id
// Game ID for sparks,
// i.e. succession factors.
pub struct spark-id
game-id: game-id
// Game ID for spark groups,
// i.e. all rarities (star counts) of a single spark.
pub struct spark-group-id
game-id: game-id
// order2 comparison between any game ID types.
pub inline fun order2(x: a, y: a, ?a/game-id: (a) -> game-id): order2<a>
match x.game-id.cmp(y.game-id)

23
horse/global/scenario.go Normal file
View File

@@ -0,0 +1,23 @@
package global
// Automatically generated with horsegen; DO NOT EDIT
import . "git.sunturtle.xyz/zephyr/horse/horse"
const (
ScenarioURAFinale ScenarioID = 1 // URA Finale
ScenarioUnityCup ScenarioID = 2 // Unity Cup
)
var AllScenarios = map[ScenarioID]Scenario{
ScenarioURAFinale: {
ID: 1,
Name: "URA Finale",
Title: "The Beginning: URA Finale",
},
ScenarioUnityCup: {
ID: 2,
Name: "Unity Cup",
Title: "Unity Cup: Shine On, Team Spirit!",
},
}

38
horse/global/scenario.kk Normal file
View File

@@ -0,0 +1,38 @@
module horse/global/scenario
// Automatically generated with horsegen; DO NOT EDIT
import horse/game-id
// Enumeration of all scenarios for type-safe programming.
pub type scenario
URA-Finale
Unity-Cup
// Get the scenario ID for a scenario.
pub fun scenario-id(s: scenario): scenario-id
match s
URA-Finale -> Scenario-id(1)
Unity-Cup -> Scenario-id(2)
// List of all scenarios in ID order for easy iterating.
pub val all = [
URA-Finale,
Unity-Cup,
]
// Get the name for a scenario.
// If no scenario matches the ID, the result contains the numeric ID.
pub fun show(s: scenario-id): string
match s.game-id
1 -> "URA Finale"
2 -> "Unity Cup"
x -> "scenario " ++ x.show
// Get the full title for a scenario, e.g. "The Beginning: URA Finale".
// If no scenario matches the ID, the result contains the numeric ID.
pub fun title(s: scenario-id): string
match s.game-id
1 -> "The Beginning: URA Finale"
2 -> "Unity Cup: Shine On, Team Spirit!"
x -> "scenario " ++ x.show

13052
horse/global/spark.go Normal file

File diff suppressed because it is too large Load Diff

12246
horse/global/spark.kk Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,33 @@
module horse/movement
// Surface types.
pub type surface
Turf
Dirt
// Automatically generated.
// Shows a string representation of the `surface` type.
pub fun surface/show(this : surface) : e string
match this
Turf -> "Turf"
Dirt -> "Dirt"
// Race distance types.
pub type distance
Sprint
Mile
Medium
Long
// Automatically generated.
// Shows a string representation of the `distance` type.
pub fun distance/show(this : distance) : e string
match this
Sprint -> "Sprint"
Mile -> "Mile"
Medium -> "Medium"
Long -> "Long"
// Running styles.
pub type style
Front-Runner

View File

@@ -35,3 +35,12 @@ const (
SaddleTypeG2
SaddleTypeG1
)
type ScenarioID int8
// Scenario is metadata about a career scenario.
type Scenario struct {
ID ScenarioID
Name string
Title string
}

87
horse/spark.go Normal file
View File

@@ -0,0 +1,87 @@
package horse
type (
SparkID int32
SparkGroupID int32
)
type Spark struct {
ID SparkID
Name string
Description string
Group SparkGroupID
Rarity SparkRarity
Type SparkType
Effects [][]SparkEffect
}
type SparkType int8
//go:generate go run golang.org/x/tools/cmd/stringer@v0.41.0 -type SparkType -trimprefix Spark
const (
SparkStat SparkType = iota + 1
SparkAptitude
SparkUnique
SparkSkill
SparkRace
SparkScenario
SparkCarnival
SparkDistance
SparkHidden
SparkSurface
SparkStyle
)
type SparkRarity int8
const (
OneStar SparkRarity = iota + 1 // ★
TwoStar // ★★
ThreeStar // ★★★
)
func (r SparkRarity) String() string {
const s = "★★★"
return s[:int(r)*len("★")]
}
type SparkEffect struct {
Target SparkTarget
Value1 int32
Value2 int32
}
type SparkTarget int8
//go:generate go run golang.org/x/tools/cmd/stringer@v0.41.0 -type SparkTarget -trimprefix Spark
const (
SparkSpeed SparkTarget = iota + 1
SparkStam
SparkPower
SparkGuts
SparkWit
SparkSkillPoints
SparkRandomStat
SparkTurf SparkTarget = 11
SparkDirt SparkTarget = 12
SparkFrontRunner SparkTarget = iota + 12
SparkPaceChaser
SparkLateSurger
SparkEndCloser
SparkSprint SparkTarget = iota + 18
SparkMile
SparkMedium
SparkLong
SparkSkillHint SparkTarget = 41
SparkCarnivalBonus SparkTarget = 51
SparkSpeedCap SparkTarget = iota + 42
SparkStamCap
SparkPowerCap
SparkGutsCap
SparkWitCap
)

View File

@@ -1,21 +1,76 @@
module horse/spark
// A single spark.
// Parameterized by the spark type: stat, aptitude, unique, race, or skill.
pub struct spark<a>
kind: a
level: level
import std/num/decimal
import horse/game-id
import horse/movement
pub fun spark/show(spark: spark<a>, level-fancy: string = "*", ?kind: (a) -> string): string
kind(spark.kind) ++ " " ++ spark.level.show ++ level-fancy
// A spark on a veteran.
pub struct spark-detail
spark-id: spark-id
typ: spark-type
rarity: rarity
pub type level
pub fun spark-detail/show(s: spark-detail, ?spark/show: (spark-id) -> string): string
s.spark-id.show ++ " " ++ "\u2605".repeat(s.rarity.int)
// The category of a spark; roughly, blue, pink, green, or white, with some
// further subdivisions.
pub type spark-type
Stat // blue
Aptitude // red/pink
Unique // green
Race
Skill
// skip Carnival Bonus
Scenario
Surface
Distance
Style
Hidden
// Spark targets and effects.
pub type spark-effect
Stat-Up(s: stat, amount: int)
SP-Up(amount: int)
// skip Carnival Bonus
Random-Stat-Up(amount: int)
Aptitude-Up(a: aptitude, amount: int)
Skill-Hint(s: skill-id, levels: int)
Stat-Cap-Up(s: stat, amount: int)
// Get the base probability for a spark to trigger during a single inheritance.
pub fun decimal/base-proc(s: spark-detail): decimal
match s
Spark-detail(_, Stat, One) -> 70.decimal(-2)
Spark-detail(_, Stat, Two) -> 80.decimal(-2)
Spark-detail(_, Stat, Three) -> 90.decimal(-2)
Spark-detail(_, Aptitude, One) -> 1.decimal(-2)
Spark-detail(_, Aptitude, Two) -> 3.decimal(-2)
Spark-detail(_, Aptitude, Three) -> 5.decimal(-2)
Spark-detail(_, Unique, One) -> 5.decimal(-2)
Spark-detail(_, Unique, Two) -> 10.decimal(-2)
Spark-detail(_, Unique, Three) -> 15.decimal(-2)
Spark-detail(_, Race, One) -> 1.decimal(-2)
Spark-detail(_, Race, Two) -> 2.decimal(-2)
Spark-detail(_, Race, Three) -> 3.decimal(-2)
Spark-detail(_, _, One) -> 3.decimal(-2)
Spark-detail(_, _, Two) -> 6.decimal(-2)
Spark-detail(_, _, Three) -> 9.decimal(-2)
// The level or star count of a spark.
pub type rarity
One
Two
Three
pub fun level/show(this: level): string
match this
pub fun rarity/int(l: rarity): int
match l
One -> 1
Two -> 2
Three -> 3
pub fun rarity/show(l: rarity): string
match l
One -> "1"
Two -> "2"
Three -> "3"
@@ -64,123 +119,3 @@ pub fun aptitude/show(this : aptitude): string
Pace-Chaser -> "Pace Chaser"
Late-Surger -> "Late Surger"
End-Closer -> "End Closer"
// Unique (green) spark.
// TODO: decide this representation; strings? umas? probably depends on skills generally
pub type unique
pub fun unique/show(this: unique): string
"TODO(zeph): unique skills"
// Race, skill, and scenario (white) sparks.
pub type generic
February-Stakes
Takamatsunomiya-Kinen
Osaka-Hai
Oka-Sho
Satsuki-Sho
Tenno-Sho-Spring
NHK-Mile-Cup
Victoria-Mile
Japanese-Oaks
Japanese-Derby
Yasuda-Kinen
Takarazuka-Kinen
Sprinters-Stakes
Shuka-Sho
Kikuka-Sho
Tenno-Sho-Autumn
Queen-Elizabeth-II-Cup
Mile-Championship
Japan-Cup
Champions-Cup
Hanshin-Juvenile-Fillies
Asahi-Hai-Futurity-Stakes
Arima-Kinen
Hopeful-Stakes
Tokyo-Daishoten
JBC-Classic
JBC-Sprint
JBC-Ladies-Classic
Japan-Dirt-Derby
Teio-Sho
Skill(skill: string)
URA-Finale
Unity-Cup
// Automatically generated.
// Equality comparison of the `generic` type.
pub fun generic/(==)(this : generic, other : generic) : e bool
match (this, other)
(February-Stakes, February-Stakes) -> True
(Takamatsunomiya-Kinen, Takamatsunomiya-Kinen) -> True
(Osaka-Hai, Osaka-Hai) -> True
(Oka-Sho, Oka-Sho) -> True
(Satsuki-Sho, Satsuki-Sho) -> True
(Tenno-Sho-Spring, Tenno-Sho-Spring) -> True
(NHK-Mile-Cup, NHK-Mile-Cup) -> True
(Victoria-Mile, Victoria-Mile) -> True
(Japanese-Oaks, Japanese-Oaks) -> True
(Japanese-Derby, Japanese-Derby) -> True
(Yasuda-Kinen, Yasuda-Kinen) -> True
(Takarazuka-Kinen, Takarazuka-Kinen) -> True
(Sprinters-Stakes, Sprinters-Stakes) -> True
(Shuka-Sho, Shuka-Sho) -> True
(Kikuka-Sho, Kikuka-Sho) -> True
(Tenno-Sho-Autumn, Tenno-Sho-Autumn) -> True
(Queen-Elizabeth-II-Cup, Queen-Elizabeth-II-Cup) -> True
(Mile-Championship, Mile-Championship) -> True
(Japan-Cup, Japan-Cup) -> True
(Champions-Cup, Champions-Cup) -> True
(Hanshin-Juvenile-Fillies, Hanshin-Juvenile-Fillies) -> True
(Asahi-Hai-Futurity-Stakes, Asahi-Hai-Futurity-Stakes) -> True
(Arima-Kinen, Arima-Kinen) -> True
(Hopeful-Stakes, Hopeful-Stakes) -> True
(Tokyo-Daishoten, Tokyo-Daishoten) -> True
(JBC-Classic, JBC-Classic) -> True
(JBC-Sprint, JBC-Sprint) -> True
(JBC-Ladies-Classic, JBC-Ladies-Classic) -> True
(Japan-Dirt-Derby, Japan-Dirt-Derby) -> True
(Teio-Sho, Teio-Sho) -> True
(Skill(skill), Skill(skill')) -> skill == skill'
(URA-Finale, URA-Finale) -> True
(Unity-Cup, Unity-Cup) -> True
(_, _) -> False
// Automatically generated.
// Shows a string representation of the `generic` type.
pub fun generic/show(this : generic) : e string
match this
February-Stakes -> "February Stakes"
Takamatsunomiya-Kinen -> "Takamatsunomiya Kinen"
Osaka-Hai -> "Osaka Hai"
Oka-Sho -> "Oka Sho"
Satsuki-Sho -> "Satsuki Sho"
Tenno-Sho-Spring -> "Tenno Sho Spring"
NHK-Mile-Cup -> "NHK Mile Cup"
Victoria-Mile -> "Victoria Mile"
Japanese-Oaks -> "Japanese Oaks"
Japanese-Derby -> "Japanese Derby"
Yasuda-Kinen -> "Yasuda Kinen"
Takarazuka-Kinen -> "Takarazuka Kinen"
Sprinters-Stakes -> "Sprinters Stakes"
Shuka-Sho -> "Shuka Sho"
Kikuka-Sho -> "Kikuka Sho"
Tenno-Sho-Autumn -> "Tenno Sho Autumn"
Queen-Elizabeth-II-Cup -> "Queen Elizabeth II Cup"
Mile-Championship -> "Mile Championship"
Japan-Cup -> "Japan Cup"
Champions-Cup -> "Champions Cup"
Hanshin-Juvenile-Fillies -> "Hanshin Juvenile Fillies"
Asahi-Hai-Futurity-Stakes -> "Asahi Hai Futurity Stakes"
Arima-Kinen -> "Arima Kinen"
Hopeful-Stakes -> "Hopeful Stakes"
Tokyo-Daishoten -> "Tokyo Daishoten"
JBC-Classic -> "JBC Classic"
JBC-Sprint -> "JBC Sprint"
JBC-Ladies-Classic -> "JBC Ladies Classic"
Japan-Dirt-Derby -> "Japan Dirt Derby"
Teio-Sho -> "Teio Sho"
Skill(skill) -> skill.show
URA-Finale -> "URA Finale"
Unity-Cup -> "Unity Cup"

View File

@@ -0,0 +1,79 @@
// Code generated by "stringer -type SparkTarget -trimprefix Spark"; 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[SparkSpeed-1]
_ = x[SparkStam-2]
_ = x[SparkPower-3]
_ = x[SparkGuts-4]
_ = x[SparkWit-5]
_ = x[SparkSkillPoints-6]
_ = x[SparkRandomStat-7]
_ = x[SparkTurf-11]
_ = x[SparkDirt-12]
_ = x[SparkFrontRunner-21]
_ = x[SparkPaceChaser-22]
_ = x[SparkLateSurger-23]
_ = x[SparkEndCloser-24]
_ = x[SparkSprint-31]
_ = x[SparkMile-32]
_ = x[SparkMedium-33]
_ = x[SparkLong-34]
_ = x[SparkSkillHint-41]
_ = x[SparkCarnivalBonus-51]
_ = x[SparkSpeedCap-61]
_ = x[SparkStamCap-62]
_ = x[SparkPowerCap-63]
_ = x[SparkGutsCap-64]
_ = x[SparkWitCap-65]
}
const (
_SparkTarget_name_0 = "SpeedStamPowerGutsWitSkillPointsRandomStat"
_SparkTarget_name_1 = "TurfDirt"
_SparkTarget_name_2 = "FrontRunnerPaceChaserLateSurgerEndCloser"
_SparkTarget_name_3 = "SprintMileMediumLong"
_SparkTarget_name_4 = "SkillHint"
_SparkTarget_name_5 = "CarnivalBonus"
_SparkTarget_name_6 = "SpeedCapStamCapPowerCapGutsCapWitCap"
)
var (
_SparkTarget_index_0 = [...]uint8{0, 5, 9, 14, 18, 21, 32, 42}
_SparkTarget_index_1 = [...]uint8{0, 4, 8}
_SparkTarget_index_2 = [...]uint8{0, 11, 21, 31, 40}
_SparkTarget_index_3 = [...]uint8{0, 6, 10, 16, 20}
_SparkTarget_index_6 = [...]uint8{0, 8, 15, 23, 30, 36}
)
func (i SparkTarget) String() string {
switch {
case 1 <= i && i <= 7:
i -= 1
return _SparkTarget_name_0[_SparkTarget_index_0[i]:_SparkTarget_index_0[i+1]]
case 11 <= i && i <= 12:
i -= 11
return _SparkTarget_name_1[_SparkTarget_index_1[i]:_SparkTarget_index_1[i+1]]
case 21 <= i && i <= 24:
i -= 21
return _SparkTarget_name_2[_SparkTarget_index_2[i]:_SparkTarget_index_2[i+1]]
case 31 <= i && i <= 34:
i -= 31
return _SparkTarget_name_3[_SparkTarget_index_3[i]:_SparkTarget_index_3[i+1]]
case i == 41:
return _SparkTarget_name_4
case i == 51:
return _SparkTarget_name_5
case 61 <= i && i <= 65:
i -= 61
return _SparkTarget_name_6[_SparkTarget_index_6[i]:_SparkTarget_index_6[i+1]]
default:
return "SparkTarget(" + strconv.FormatInt(int64(i), 10) + ")"
}
}

34
horse/sparktype_string.go Normal file
View File

@@ -0,0 +1,34 @@
// Code generated by "stringer -type SparkType -trimprefix Spark"; 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[SparkStat-1]
_ = x[SparkAptitude-2]
_ = x[SparkUnique-3]
_ = x[SparkSkill-4]
_ = x[SparkRace-5]
_ = x[SparkScenario-6]
_ = x[SparkCarnival-7]
_ = x[SparkDistance-8]
_ = x[SparkHidden-9]
_ = x[SparkSurface-10]
_ = x[SparkStyle-11]
}
const _SparkType_name = "StatAptitudeUniqueSkillRaceScenarioCarnivalDistanceHiddenSurfaceStyle"
var _SparkType_index = [...]uint8{0, 4, 12, 18, 23, 27, 35, 43, 51, 57, 64, 69}
func (i SparkType) String() string {
idx := int(i) - 1
if i < 1 || idx >= len(_SparkType_index)-1 {
return "SparkType(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _SparkType_name[_SparkType_index[idx]:_SparkType_index[idx+1]]
}

View File

@@ -123,6 +123,37 @@ func ExecSaddle(t *template.Template, region string, kk, g io.Writer, saddles []
return err
}
func ExecScenario(t *template.Template, region string, kk, g io.Writer, scen []Scenario) error {
data := struct {
Region string
Scenarios []Scenario
}{region, scen}
var err error
if kk != nil {
err = errors.Join(err, t.ExecuteTemplate(kk, "koka-scenario", &data))
}
if g != nil {
err = errors.Join(err, t.ExecuteTemplate(g, "go-scenario", &data))
}
return err
}
func ExecSparks(t *template.Template, region string, kk, g io.Writer, sparks []Spark, effects map[int]map[int][]SparkEffect) error {
data := struct {
Region string
Sparks []Spark
SparkEffects map[int]map[int][]SparkEffect
}{region, sparks, effects}
var err error
if kk != nil {
err = errors.Join(err, t.ExecuteTemplate(kk, "koka-spark", &data))
}
if g != nil {
err = errors.Join(err, t.ExecuteTemplate(g, "go-spark", &data))
}
return err
}
const wordSeps = " ,!?/-+();#○☆♡'=♪∀゚∴"
var (

View File

@@ -29,6 +29,15 @@ var raceSQL string
//go:embed saddle.sql
var saddleSQL string
//go:embed scenario.sql
var scenarioSQL string
//go:embed spark.sql
var sparkSQL string
//go:embed spark-effect.sql
var sparkEffectSQL string
type (
Character struct{}
SkillGroup struct{}
@@ -407,3 +416,125 @@ func Saddles(ctx context.Context, db *sqlitex.Pool) ([]Saddle, error) {
}
return r, nil
}
type Scenario struct {
ID int
Name string
Title string
}
func Scenarios(ctx context.Context, db *sqlitex.Pool) ([]Scenario, error) {
conn, err := db.Take(ctx)
defer db.Put(conn)
if err != nil {
return nil, fmt.Errorf("couldn't get connection for scenario: %w", err)
}
stmt, _, err := conn.PrepareTransient(scenarioSQL)
if err != nil {
return nil, fmt.Errorf("couldn't prepare statement for scenario: %w", err)
}
defer stmt.Finalize()
var r []Scenario
for {
ok, err := stmt.Step()
if err != nil {
return nil, fmt.Errorf("error stepping scenarios: %w", err)
}
if !ok {
break
}
s := Scenario{
ID: stmt.ColumnInt(0),
Name: stmt.ColumnText(1),
Title: stmt.ColumnText(2),
}
r = append(r, s)
}
return r, nil
}
type Spark struct {
ID int
Name string
Description string
Group int
Rarity int
Type int
}
type SparkEffect struct {
Target int
Value1 int
Value2 int
}
func Sparks(ctx context.Context, db *sqlitex.Pool) ([]Spark, error) {
conn, err := db.Take(ctx)
defer db.Put(conn)
if err != nil {
return nil, fmt.Errorf("couldn't get connection for sparks: %w", err)
}
stmt, _, err := conn.PrepareTransient(sparkSQL)
if err != nil {
return nil, fmt.Errorf("couldn't prepare statement for sparks: %w", err)
}
defer stmt.Finalize()
var r []Spark
for {
ok, err := stmt.Step()
if err != nil {
return nil, fmt.Errorf("error stepping sparks: %w", err)
}
if !ok {
break
}
s := Spark{
ID: stmt.ColumnInt(0),
Name: stmt.ColumnText(1),
Description: stmt.ColumnText(2),
Group: stmt.ColumnInt(3),
Rarity: stmt.ColumnInt(4),
Type: stmt.ColumnInt(5),
}
r = append(r, s)
}
return r, nil
}
func SparkEffects(ctx context.Context, db *sqlitex.Pool) (map[int]map[int][]SparkEffect, error) {
conn, err := db.Take(ctx)
defer db.Put(conn)
if err != nil {
return nil, fmt.Errorf("couldn't get connection for spark effects: %w", err)
}
stmt, _, err := conn.PrepareTransient(sparkEffectSQL)
if err != nil {
return nil, fmt.Errorf("couldn't prepare statement for spark effects: %w", err)
}
defer stmt.Finalize()
r := make(map[int]map[int][]SparkEffect)
for {
ok, err := stmt.Step()
if err != nil {
return nil, fmt.Errorf("error stepping spark effects: %w", err)
}
if !ok {
break
}
group := stmt.ColumnInt(0)
eff := stmt.ColumnInt(1)
s := SparkEffect{
Target: stmt.ColumnInt(2),
Value1: stmt.ColumnInt(3),
Value2: stmt.ColumnInt(4),
}
if r[group] == nil {
r[group] = make(map[int][]SparkEffect)
}
r[group][eff] = append(r[group][eff], s)
}
return r, nil
}

View File

@@ -45,13 +45,16 @@ func main() {
eg, ctx := errgroup.WithContext(pctx)
var (
charas []NamedID[Character]
pairs []AffinityRelation
trios []AffinityRelation
sg []NamedID[SkillGroup]
skills []Skill
races []Race
saddles []Saddle
charas []NamedID[Character]
pairs []AffinityRelation
trios []AffinityRelation
sg []NamedID[SkillGroup]
skills []Skill
races []Race
saddles []Saddle
scens []Scenario
sparks []Spark
sparkeff map[int]map[int][]SparkEffect
)
eg.Go(func() error {
slog.Info("get characters")
@@ -91,8 +94,26 @@ func main() {
})
eg.Go(func() error {
slog.Info("get saddles")
s, err := Saddles(ctx, db)
saddles = s
r, err := Saddles(ctx, db)
saddles = r
return err
})
eg.Go(func() error {
slog.Info("get scenarios")
r, err := Scenarios(ctx, db)
scens = r
return err
})
eg.Go(func() error {
slog.Info("get sparks")
r, err := Sparks(ctx, db)
sparks = r
return err
})
eg.Go(func() error {
slog.Info("get spark effects")
r, err := SparkEffects(ctx, db)
sparkeff = r
return err
})
if err := eg.Wait(); err != nil {
@@ -154,6 +175,30 @@ func main() {
slog.Info("write saddles")
return ExecSaddle(t, region, kf, gf, saddles)
})
eg.Go(func() error {
kf, err := os.Create(filepath.Join(out, region, "scenario.kk"))
if err != nil {
return err
}
gf, err := os.Create(filepath.Join(out, region, "scenario.go"))
if err != nil {
return err
}
slog.Info("write scenarios")
return ExecScenario(t, region, kf, gf, scens)
})
eg.Go(func() error {
kf, err := os.Create(filepath.Join(out, region, "spark.kk"))
if err != nil {
return err
}
gf, err := os.Create(filepath.Join(out, region, "spark.go"))
if err != nil {
return err
}
slog.Info("write sparks")
return ExecSparks(t, region, kf, gf, sparks, sparkeff)
})
if err := eg.Wait(); err != nil {
slog.Error("generate", slog.Any("err", err))
os.Exit(1)

View File

@@ -0,0 +1,23 @@
{{- define "go-scenario" -}}
package {{ $.Region }}
// Automatically generated with horsegen; DO NOT EDIT
import . "git.sunturtle.xyz/zephyr/horse/horse"
const (
{{- range $s := $.Scenarios }}
Scenario{{ goenum $s.Name }} ScenarioID = {{ $s.ID }} // {{ $s.Name }}
{{- end }}
)
var AllScenarios = map[ScenarioID]Scenario{
{{- range $s := $.Scenarios }}
Scenario{{ goenum $s.Name }}: {
ID: {{ $s.ID }},
Name: {{ printf "%q" $s.Name }},
Title: {{ printf "%q" $s.Title }},
},
{{- end }}
}
{{ end }}

View File

@@ -0,0 +1,45 @@
{{- define "koka-scenario" -}}
module horse/{{ $.Region }}/scenario
// Automatically generated with horsegen; DO NOT EDIT
import horse/game-id
// Enumeration of all scenarios for type-safe programming.
pub type scenario
{{- range $s := $.Scenarios }}
{{ kkenum $s.Name }}
{{- end }}
// Get the scenario ID for a scenario.
pub fun scenario-id(s: scenario): scenario-id
match s
{{- range $s := $.Scenarios }}
{{ kkenum $s.Name }} -> Scenario-id({{ $s.ID }})
{{- end }}
// List of all scenarios in ID order for easy iterating.
pub val all = [
{{- range $s := $.Scenarios }}
{{ kkenum $s.Name }},
{{- end }}
]
// Get the name for a scenario.
// If no scenario matches the ID, the result contains the numeric ID.
pub fun show(s: scenario-id): string
match s.game-id
{{- range $s := $.Scenarios }}
{{ $s.ID }} -> {{ printf "%q" $s.Name }}
{{- end }}
x -> "scenario " ++ x.show
// Get the full title for a scenario, e.g. "The Beginning: URA Finale".
// If no scenario matches the ID, the result contains the numeric ID.
pub fun title(s: scenario-id): string
match s.game-id
{{- range $s := $.Scenarios }}
{{ $s.ID }} -> {{ printf "%q" $s.Title }}
{{- end }}
x -> "scenario " ++ x.show
{{ end }}

17
horsegen/scenario.sql Normal file
View File

@@ -0,0 +1,17 @@
WITH scenario_name AS (
SELECT "index" AS id, "text" AS name
FROM text_data
WHERE category = 237
), scenario_title AS (
SELECT "index" AS id, "text" AS title
FROM text_data
WHERE category = 119
)
SELECT
sc.id,
n.name,
t.title
FROM single_mode_scenario sc
JOIN scenario_name n ON sc.id = n.id
JOIN scenario_title t ON sc.id = t.id
ORDER BY sc.id

View File

@@ -0,0 +1,9 @@
SELECT
factor_group_id,
effect_id,
target_type,
value_1,
value_2
FROM succession_factor_effect
WHERE factor_group_id NOT IN (40001) -- exclude Carnival Bonus
ORDER BY factor_group_id, effect_id, target_type

View File

@@ -0,0 +1,35 @@
{{- define "go-spark" -}}
package {{ $.Region }}
// Automatically generated with horsegen; DO NOT EDIT
import . "git.sunturtle.xyz/zephyr/horse/horse"
const (
{{- range $s := $.Sparks }}
Spark{{ goenum $s.Name }}Lv{{ $s.Rarity }} SparkID = {{ $s.ID }} // {{ $s.Name }}
{{- end }}
)
var AllSparks = map[SparkID]Spark{
{{- range $s := $.Sparks }}
Spark{{ goenum $s.Name }}Lv{{ $s.Rarity }}: {
ID: {{ $s.ID }},
Name: {{ printf "%q" $s.Name }},
Description: {{ printf "%q" $s.Description }},
Group: {{ $s.Group }},
Rarity: {{ $s.Rarity }},
Type: {{ $s.Type }},
Effects: [][]SparkEffect{
{{- range $r := index $.SparkEffects $s.Group }}
{
{{- range $e := $r -}}
{ {{- $e.Target }}, {{ $e.Value1 }}, {{ $e.Value2 -}} },
{{- end -}}
},
{{- end }}
},
},
{{- end }}
}
{{ end }}

132
horsegen/spark.kk.template Normal file
View File

@@ -0,0 +1,132 @@
{{- 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<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 }}

20
horsegen/spark.sql Normal file
View File

@@ -0,0 +1,20 @@
WITH spark AS (
SELECT
n."index" AS "id",
n."text" AS "name",
d."text" AS "description"
FROM text_data n
LEFT JOIN text_data d ON n."index" = d."index" AND d."category" = 172
WHERE n.category = 147
)
SELECT
sf.factor_id,
spark.name,
spark.description,
sf.factor_group_id,
sf.rarity,
sf.factor_type
FROM spark
JOIN succession_factor sf ON spark.id = sf.factor_id
WHERE sf.factor_type != 7 -- exclude Carnival Bonus
ORDER BY sf.factor_id