cmd/factorfactor: initial work
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"git.sunturtle.xyz/zephyr/horse"
|
||||
"git.sunturtle.xyz/zephyr/horse/umadump/ism"
|
||||
)
|
||||
|
||||
// For each gain type from inspiration (stats, caps, aptitudes, skills):
|
||||
// find all activated sparks that can give that gain type.
|
||||
// Then, find all subsets of effect groups among those sparks
|
||||
// that have effects summing to those observed
|
||||
// (or more if the .end_info result is maxed),
|
||||
// with the restriction that one comes from each spark.
|
||||
// Deduplicate permutations.
|
||||
// Lastly, find the intersection of possible effects from sparks that appear
|
||||
// multiple times.
|
||||
//
|
||||
// To some extent, we rely on there being no sparks with the random stats effect type,
|
||||
// although we also don't know the distribution of stats from overcapped skill hints.
|
||||
|
||||
type target struct {
|
||||
spark *horse.Spark
|
||||
group int
|
||||
effect horse.SparkEffect
|
||||
}
|
||||
|
||||
func skilltargets(sparks []horse.Spark) map[horse.SkillID]map[horse.SparkID][]target {
|
||||
r := make(map[horse.SkillID]map[horse.SparkID][]target)
|
||||
for i, sp := range sparks {
|
||||
for j, g := range sp.Effects {
|
||||
for _, e := range g {
|
||||
if e.Target != horse.SparkSkillHint {
|
||||
continue
|
||||
}
|
||||
if r[horse.SkillID(e.Value1)] == nil {
|
||||
r[horse.SkillID(e.Value1)] = make(map[horse.SparkID][]target)
|
||||
}
|
||||
r[horse.SkillID(e.Value1)][sp.ID] = append(r[horse.SkillID(e.Value1)][sp.ID], target{&sparks[i], j, e})
|
||||
}
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func resolveSkills(tab tables, career *ism.WorkIdleSingleMode)
|
||||
|
||||
// skillsparks appends all activated sparks that can yield a given skill to r.
|
||||
// It assumes that no spark can give multiple skills.
|
||||
func skillsparks(tab tables, sparks []ism.Factor, id horse.SkillID, r []*horse.Spark) []*horse.Spark {
|
||||
for _, f := range sparks {
|
||||
sp := tab.sparks[f.FactorID]
|
||||
if sp == nil {
|
||||
// ATM we do generally exclude Carnival Bonus from spark info.
|
||||
// Better to check.
|
||||
slog.Warn("skipped spark", slog.Int("id", int(f.FactorID)))
|
||||
continue
|
||||
}
|
||||
if sparkHasSkill(sp, id) {
|
||||
r = append(r, sp)
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func sparkHasSkill(sp *horse.Spark, id horse.SkillID) bool {
|
||||
for _, g := range sp.Effects {
|
||||
for _, e := range g {
|
||||
if e.Target != horse.SparkSkillHint {
|
||||
continue
|
||||
}
|
||||
return id == horse.SkillID(e.Value1)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user