horsegen: generate sparks
This commit is contained in:
@@ -24,6 +24,11 @@ factor_type:
|
|||||||
- 5 race
|
- 5 race
|
||||||
- 4 skill
|
- 4 skill
|
||||||
- 6 scenario
|
- 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
|
- 3 unique
|
||||||
|
|
||||||
target_type:
|
target_type:
|
||||||
@@ -32,6 +37,8 @@ target_type:
|
|||||||
- 3 power
|
- 3 power
|
||||||
- 4 guts
|
- 4 guts
|
||||||
- 5 wit
|
- 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
|
- 11 turf; value 1 is number of levels (1 or 2), value 2 is 0
|
||||||
- 12 dirt
|
- 12 dirt
|
||||||
- 21 front
|
- 21 front
|
||||||
@@ -42,7 +49,15 @@ target_type:
|
|||||||
- 32 mile
|
- 32 mile
|
||||||
- 33 medium
|
- 33 medium
|
||||||
- 34 long
|
- 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.
|
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.
|
effect_id distinguishes possibilities; factors with multiple effects (race and scenario sparks) have multiple rows with equal effect_id.
|
||||||
|
|||||||
@@ -46,6 +46,16 @@ pub struct race-thumbnail-id
|
|||||||
pub struct saddle-id
|
pub struct saddle-id
|
||||||
game-id: game-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.
|
// order2 comparison between any game ID types.
|
||||||
pub inline fun order2(x: a, y: a, ?a/game-id: (a) -> game-id): order2<a>
|
pub inline fun order2(x: a, y: a, ?a/game-id: (a) -> game-id): order2<a>
|
||||||
match x.game-id.cmp(y.game-id)
|
match x.game-id.cmp(y.game-id)
|
||||||
|
|||||||
13052
horse/global/spark.go
Normal file
13052
horse/global/spark.go
Normal file
File diff suppressed because it is too large
Load Diff
12245
horse/global/spark.kk
Normal file
12245
horse/global/spark.kk
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,33 @@
|
|||||||
module horse/movement
|
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.
|
// Running styles.
|
||||||
pub type style
|
pub type style
|
||||||
Front-Runner
|
Front-Runner
|
||||||
|
|||||||
87
horse/spark.go
Normal file
87
horse/spark.go
Normal 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
|
||||||
|
)
|
||||||
@@ -1,22 +1,76 @@
|
|||||||
module horse/spark
|
module horse/spark
|
||||||
|
|
||||||
|
import std/num/decimal
|
||||||
import horse/game-id
|
import horse/game-id
|
||||||
|
import horse/movement
|
||||||
|
|
||||||
pub type spark
|
// A spark on a veteran.
|
||||||
Stat(s: stat, l: level)
|
pub struct spark-detail
|
||||||
Aptitude(a: aptitude, l: level)
|
spark-id: spark-id
|
||||||
Unique(s: skill-id, l: level)
|
typ: spark-type
|
||||||
Race(r: race-id, l: level)
|
rarity: rarity
|
||||||
Skill(s: skill-id, l: level)
|
|
||||||
Scenario(s: scenario-id, l: level)
|
|
||||||
|
|
||||||
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
|
One
|
||||||
Two
|
Two
|
||||||
Three
|
Three
|
||||||
|
|
||||||
pub fun level/show(this: level): string
|
pub fun rarity/int(l: rarity): int
|
||||||
match this
|
match l
|
||||||
|
One -> 1
|
||||||
|
Two -> 2
|
||||||
|
Three -> 3
|
||||||
|
|
||||||
|
pub fun rarity/show(l: rarity): string
|
||||||
|
match l
|
||||||
One -> "1"
|
One -> "1"
|
||||||
Two -> "2"
|
Two -> "2"
|
||||||
Three -> "3"
|
Three -> "3"
|
||||||
|
|||||||
79
horse/sparktarget_string.go
Normal file
79
horse/sparktarget_string.go
Normal 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
34
horse/sparktype_string.go
Normal 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]]
|
||||||
|
}
|
||||||
@@ -138,6 +138,22 @@ func ExecScenario(t *template.Template, region string, kk, g io.Writer, scen []S
|
|||||||
return err
|
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 = " ,!?/-+();#○☆♡'=♪∀゚∴"
|
const wordSeps = " ,!?/-+();#○☆♡'=♪∀゚∴"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ var saddleSQL string
|
|||||||
//go:embed scenario.sql
|
//go:embed scenario.sql
|
||||||
var scenarioSQL string
|
var scenarioSQL string
|
||||||
|
|
||||||
|
//go:embed spark.sql
|
||||||
|
var sparkSQL string
|
||||||
|
|
||||||
|
//go:embed spark-effect.sql
|
||||||
|
var sparkEffectSQL string
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Character struct{}
|
Character struct{}
|
||||||
SkillGroup struct{}
|
SkillGroup struct{}
|
||||||
@@ -447,3 +453,88 @@ func Scenarios(ctx context.Context, db *sqlitex.Pool) ([]Scenario, error) {
|
|||||||
}
|
}
|
||||||
return r, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,14 +45,16 @@ func main() {
|
|||||||
|
|
||||||
eg, ctx := errgroup.WithContext(pctx)
|
eg, ctx := errgroup.WithContext(pctx)
|
||||||
var (
|
var (
|
||||||
charas []NamedID[Character]
|
charas []NamedID[Character]
|
||||||
pairs []AffinityRelation
|
pairs []AffinityRelation
|
||||||
trios []AffinityRelation
|
trios []AffinityRelation
|
||||||
sg []NamedID[SkillGroup]
|
sg []NamedID[SkillGroup]
|
||||||
skills []Skill
|
skills []Skill
|
||||||
races []Race
|
races []Race
|
||||||
saddles []Saddle
|
saddles []Saddle
|
||||||
scens []Scenario
|
scens []Scenario
|
||||||
|
sparks []Spark
|
||||||
|
sparkeff map[int]map[int][]SparkEffect
|
||||||
)
|
)
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
slog.Info("get characters")
|
slog.Info("get characters")
|
||||||
@@ -102,6 +104,18 @@ func main() {
|
|||||||
scens = r
|
scens = r
|
||||||
return err
|
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 {
|
if err := eg.Wait(); err != nil {
|
||||||
slog.Error("load", slog.Any("err", err))
|
slog.Error("load", slog.Any("err", err))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -173,6 +187,18 @@ func main() {
|
|||||||
slog.Info("write scenarios")
|
slog.Info("write scenarios")
|
||||||
return ExecScenario(t, region, kf, gf, scens)
|
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 {
|
if err := eg.Wait(); err != nil {
|
||||||
slog.Error("generate", slog.Any("err", err))
|
slog.Error("generate", slog.Any("err", err))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
9
horsegen/spark-effect.sql
Normal file
9
horsegen/spark-effect.sql
Normal 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
|
||||||
35
horsegen/spark.go.template
Normal file
35
horsegen/spark.go.template
Normal 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 }}
|
||||||
131
horsegen/spark.kk.template
Normal file
131
horsegen/spark.kk.template
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
{{- 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
20
horsegen/spark.sql
Normal 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
|
||||||
Reference in New Issue
Block a user