大世界ability相关交互完善第二弹
This commit is contained in:
1 parent
0750f2a984
commit
7f2fa99a82
25 files changed
+323
-342
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hk4e/pkg/logger"
|
||||
"os"
|
||||
|
||||
"github.com/hjson/hjson-go/v4"
|
||||
)
|
||||
|
||||
type ConfigGlobalCombat struct {
|
||||
DefaultAbilities struct {
|
||||
DefaultAvatarAbilities []string `json:"defaultAvatarAbilities"`
|
||||
} `json:"defaultAbilities"`
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadDefaultAbilityJsonConfig() {
|
||||
CONF.DefaultAbilityNameList = make([]string, 0)
|
||||
filePath := g.jsonPrefix + "common/ConfigGlobalCombat.json"
|
||||
fileData, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("open file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
if fileData[0] == 0xEF && fileData[1] == 0xBB && fileData[2] == 0xBF {
|
||||
fileData = fileData[3:]
|
||||
}
|
||||
configGlobalCombat := new(ConfigGlobalCombat)
|
||||
err = hjson.Unmarshal(fileData, configGlobalCombat)
|
||||
if err != nil {
|
||||
logger.Info("parse file error: %v, path: %v", err, filePath)
|
||||
panic(err)
|
||||
}
|
||||
for _, defaultAbilityName := range configGlobalCombat.DefaultAbilities.DefaultAvatarAbilities {
|
||||
CONF.DefaultAbilityNameList = append(CONF.DefaultAbilityNameList, defaultAbilityName)
|
||||
}
|
||||
}
|
||||
|
||||
func GetDefaultAbilityNameList() []string {
|
||||
return CONF.DefaultAbilityNameList
|
||||
}
|
||||
Reference in new issue
Block a user