chore: checkpoint stable battle and eidolon progression
This commit is contained in:
1 parent
365e66ffe0
commit
a681affdb3
23 files changed
+34511
-11310
No files matched your search
+44
-3
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@@ -76,6 +77,7 @@ type LevelOutputConfig struct {
|
||||
type AvatarConfig struct {
|
||||
WeaknessBuffID uint32 `json:"weaknessBuffId"`
|
||||
DamageType string `json:"damageType"`
|
||||
MaxRank uint32 `json:"maxRank"`
|
||||
}
|
||||
|
||||
type JsonConfig struct {
|
||||
@@ -85,6 +87,7 @@ type JsonConfig struct {
|
||||
MapDefaultEntranceMap map[uint32]uint32 `json:"mapDefaultEntranceMap"`
|
||||
RelicAvatarRecommend map[uint32][]uint32 `json:"relicAvatarRecommend"`
|
||||
SkinIDs []uint32 `json:"skinIds"`
|
||||
AvatarSkillTreePoints map[uint32]map[uint32]uint32 `json:"-"`
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -146,15 +149,23 @@ type AnchorConfigFile struct {
|
||||
AnchorConfig []AnchorConfigEntry `json:"anchor_config"`
|
||||
}
|
||||
|
||||
func readResourceFile(paths ...string) ([]byte, error) {
|
||||
// ReadResourceFile reads a resource file checking current directory and parent directories.
|
||||
func ReadResourceFile(paths ...string) ([]byte, error) {
|
||||
for _, p := range paths {
|
||||
if raw, err := os.ReadFile(p); err == nil {
|
||||
return raw, nil
|
||||
for _, prefix := range []string{"", "..", "../..", "../../.."} {
|
||||
target := filepath.Join(prefix, p)
|
||||
if raw, err := os.ReadFile(target); err == nil {
|
||||
return raw, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
|
||||
func readResourceFile(paths ...string) ([]byte, error) {
|
||||
return ReadResourceFile(paths...)
|
||||
}
|
||||
|
||||
// GameRes lazily parses res.json and merges supplementary configs from resources/
|
||||
func GameRes() (*JsonConfig, error) {
|
||||
gameResOnce.Do(func() {
|
||||
@@ -186,6 +197,34 @@ func GameRes() (*JsonConfig, error) {
|
||||
}
|
||||
|
||||
func loadSupplementaryResources(res *JsonConfig) {
|
||||
// AvatarSkillTreeConfig: maps AvatarID and AnchorType (e.g. Point01 -> 1) to real PointID
|
||||
if raw, err := readResourceFile("resources/AvatarSkillTreeConfig.json", "AvatarSkillTreeConfig.json"); err == nil {
|
||||
var tree struct {
|
||||
Entries []struct {
|
||||
AvatarID uint32 `json:"AvatarID"`
|
||||
PointID uint32 `json:"PointID"`
|
||||
AnchorType string `json:"AnchorType"`
|
||||
} `json:"avatar_skill_tree"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &tree); err == nil {
|
||||
if res.AvatarSkillTreePoints == nil {
|
||||
res.AvatarSkillTreePoints = make(map[uint32]map[uint32]uint32)
|
||||
}
|
||||
for _, entry := range tree.Entries {
|
||||
if entry.AvatarID == 0 || entry.PointID == 0 {
|
||||
continue
|
||||
}
|
||||
var anchorNum uint32
|
||||
if n, _ := fmt.Sscanf(entry.AnchorType, "Point%d", &anchorNum); n == 1 {
|
||||
if res.AvatarSkillTreePoints[entry.AvatarID] == nil {
|
||||
res.AvatarSkillTreePoints[entry.AvatarID] = make(map[uint32]uint32)
|
||||
}
|
||||
res.AvatarSkillTreePoints[entry.AvatarID][anchorNum] = entry.PointID
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PearlSR's resource export keeps avatar data in AvatarConfig.json;
|
||||
// res.json may legitimately contain an empty avatarConfigs object.
|
||||
if raw, err := readResourceFile("resources/AvatarConfig.json"); err == nil {
|
||||
@@ -193,12 +232,14 @@ func loadSupplementaryResources(res *JsonConfig) {
|
||||
Entries []struct {
|
||||
ID uint32 `json:"AvatarID"`
|
||||
DamageType string `json:"DamageType"`
|
||||
MaxRank uint32 `json:"MaxRank"`
|
||||
} `json:"avatar_config"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &avatars); err == nil {
|
||||
for _, avatar := range avatars.Entries {
|
||||
cfg := res.AvatarConfigs[avatar.ID]
|
||||
cfg.DamageType = avatar.DamageType
|
||||
cfg.MaxRank = avatar.MaxRank
|
||||
res.AvatarConfigs[avatar.ID] = cfg
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user