chore: checkpoint stable battle and eidolon progression

This commit is contained in:
CAtlas0784 committed 2026-10-17 16:38:03 +07:00
1 parent 365e66ffe0
commit a681affdb3
23 files changed
+34511 -11310

No files matched your search

+28 -29
View File
@@ -8,7 +8,6 @@ package common
import (
"encoding/json"
"fmt"
"os"
"sort"
)
@@ -149,6 +148,23 @@ type SubAffix struct {
Step uint32 `json:"step"`
}
func (s *SubAffix) UnmarshalJSON(data []byte) error {
type Alias SubAffix
aux := &struct {
Cnt *uint32 `json:"cnt"`
*Alias
}{
Alias: (*Alias)(s),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
if aux.Cnt != nil && s.Count == 0 {
s.Count = *aux.Cnt
}
return nil
}
type Relic struct {
Level uint32 `json:"level"`
RelicID uint32 `json:"relic_id"`
@@ -352,6 +368,8 @@ func DefaultPersistent() Persistent {
// ---------------------------------------------------------------------------
type FreesrData struct {
persistentBaseline map[string]any
Lightcones []Lightcone `json:"lightcones"`
Relics []Relic `json:"relics"`
Avatars map[uint32]*AvatarJson `json:"avatars"`
@@ -372,7 +390,7 @@ type FreesrData struct {
// LoadFreesrData reads freesr-data.json + persistent and merges them,
// mirroring FreesrData::load() from the Rust crate.
func LoadFreesrData() (*FreesrData, error) {
raw, err := os.ReadFile("freesr-data.json")
raw, err := readResourceFile("freesr-data.json")
if err != nil {
return nil, fmt.Errorf("failed to read freesr-data.json: %w", err)
}
@@ -390,7 +408,7 @@ func LoadFreesrData() (*FreesrData, error) {
}
// persistent is optional
pers, err := os.ReadFile("persistent")
pers, err := readResourceFile("persistent")
if err == nil {
var p Persistent
if err := json.Unmarshal(pers, &p); err == nil {
@@ -440,6 +458,10 @@ func LoadFreesrData() (*FreesrData, error) {
data.MarchType = MultiPathMarchHunt
}
data.persistentBaseline, err = jsonObject(data.persistentSnapshot())
if err != nil {
return nil, err
}
return &data, nil
}
@@ -453,7 +475,7 @@ func (f *FreesrData) SortedLineupKeys() []uint32 {
return keys
}
// VerifyLineup pads the lineup to 4 slots, defaulting to {0:8001}, then saves.
// VerifyLineup normalizes slots in memory. Reading a save must not rewrite it.
func (f *FreesrData) VerifyLineup() {
if len(f.Lineups) == 0 {
f.Lineups = map[uint32]uint32{0: 8001, 1: 0, 2: 0, 3: 0}
@@ -464,35 +486,12 @@ func (f *FreesrData) VerifyLineup() {
}
}
}
f.SavePersistent()
}
// SavePersistent writes the persistent subset back to the "persistent" file.
func (f *FreesrData) SavePersistent() {
exUnlocked := make(map[uint32]bool)
for aid, av := range f.Avatars {
if av.ExRankUnlocked {
exUnlocked[aid] = true
}
}
p := Persistent{
Lineups: f.Lineups,
Position: f.Position,
Scene: f.Scene,
MainCharacter: f.MainCharacter,
MarchType: f.MarchType,
EnableSWGlobal: f.EnableSWGlobal,
EnableCastoriceGlobal: f.EnableCastoriceGlobal,
EnableAhaGlobal: f.EnableAhaGlobal,
DressedSkins: f.DressedSkins,
ExRanksUnlocked: exUnlocked,
}
out, err := json.MarshalIndent(p, "", " ")
if err != nil {
return
}
if err := os.WriteFile("persistent", out, 0o644); err == nil {
LogInfo("persistent saved")
if err := f.SavePersistentChecked(); err != nil {
LogInfo("[SAVE ERROR] %v", err)
}
}