diff --git a/cmd/ismdb/main.go b/cmd/ismdb/main.go index 885673c..5095b48 100644 --- a/cmd/ismdb/main.go +++ b/cmd/ismdb/main.go @@ -1,6 +1,7 @@ package main import ( + "cmp" "context" "encoding/json" "flag" @@ -21,7 +22,7 @@ func main() { ) flag.StringVar(&uri, "db", "idle_single_mode.sqlite3", "output database `URI` or filename") flag.StringVar(&journalMode, "journal", "memory", "journal `mode` to apply to database connections") - flag.Int64Var(&trainer, "t", 0, "trainer `ID` to associate with the data") + flag.Int64Var(&trainer, "t", 0, "fallback trainer `ID` to associate with the data") flag.TextVar(&logLevel, "log", slog.LevelInfo, "log `level`") flag.Func("d", "`dir`ectory containing idle single mode dumps to load (repeatable)", func(s string) error { es, err := os.ReadDir(s) @@ -62,7 +63,9 @@ func main() { continue } log.Debug("insert") - err = insert(ctx, db, log, &career, trainer) + endTrainer, _ := career.Extra.TrainedChara["viewer_id"].(float64) + t := cmp.Or(career.Extra.ViewerID, int64(endTrainer), trainer) + err = insert(ctx, db, log, &career, t) if err != nil { log.Error("insert", slog.Any("err", err)) continue diff --git a/umadump/ism/ism.go b/umadump/ism/ism.go index bc58d0d..3a37b1a 100644 --- a/umadump/ism/ism.go +++ b/umadump/ism/ism.go @@ -340,9 +340,14 @@ type ProgressInfo struct { StoryEventCharaBonuses []umadump.Never `json:"story_event_chara_bonus_list"` } +type Extra struct { + ViewerID int64 `json:"viewer_id"` + TrainedChara map[string]any `json:"trained_chara"` +} + type WorkIdleSingleMode struct { ProgressInfo ProgressInfo `json:"progress_info"` ProgressLog IdleSingleModeProgressLog `json:"progress_log_info"` End End `json:"end_info"` - Extra map[string]any `json:"extra_data"` + Extra Extra `json:"extra_data"` }