refactor(fight/xmlres): 重构效果参数处理逻辑,新增JSON解析支持并优化战斗伤害计算
This commit is contained in:
21
common/data/xmlres/effectarg.go
Normal file
21
common/data/xmlres/effectarg.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package xmlres
|
||||
|
||||
type EffectArg struct {
|
||||
SideEffects struct {
|
||||
SideEffect []struct {
|
||||
ID int `json:"ID"`
|
||||
SideEffectArgcount int `json:"SideEffectArgcount"`
|
||||
SideEffectArg string `json:"SideEffectArg,omitempty"`
|
||||
} `json:"SideEffect"`
|
||||
} `json:"SideEffects"`
|
||||
}
|
||||
|
||||
var EffectArgs map[int]int
|
||||
|
||||
func init() {
|
||||
EffectArgs = make(map[int]int)
|
||||
for _, t := range EffectArgsConfig.SideEffects.SideEffect {
|
||||
EffectArgs[t.ID] = t.SideEffectArgcount
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package xmlres
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/ECUST-XX/xml"
|
||||
@@ -23,11 +24,21 @@ func getXml[T any](path string) T {
|
||||
|
||||
return xmls
|
||||
}
|
||||
func getJson[T any](path string) T {
|
||||
|
||||
// 解析XML到结构体
|
||||
var xmls T
|
||||
t1 := gfile.GetBytes(path)
|
||||
json.Unmarshal(t1, &xmls)
|
||||
|
||||
return xmls
|
||||
}
|
||||
|
||||
var (
|
||||
MapConfig Maps //地图配置
|
||||
ItemsConfig Items //物品配置
|
||||
TalkConfig TalkCount //任务配置
|
||||
MapConfig Maps //地图配置
|
||||
ItemsConfig Items //物品配置
|
||||
EffectArgsConfig EffectArg //arg参数
|
||||
TalkConfig TalkCount //任务配置
|
||||
//Monster MonsterRoot //野怪配置
|
||||
MonsterMap map[int]TMapConfig
|
||||
//Skill MovesTbl //技能配置
|
||||
@@ -44,7 +55,7 @@ func initfile() {
|
||||
path = path1 + "/public/config/"
|
||||
MapConfig = getXml[Maps](path + "210.xml")
|
||||
ItemsConfig = getXml[Items](path + "43.xml")
|
||||
|
||||
EffectArgsConfig = getJson[EffectArg](path + "side_effect.json")
|
||||
ItemsMAP = utils.ToMap[Item, int](ItemsConfig.Items, func(m Item) int {
|
||||
return m.ID
|
||||
|
||||
|
||||
Reference in New Issue
Block a user