mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
简化配置表读取
This commit is contained in:
+12
-35
@@ -1,40 +1,28 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"github.com/jszwec/csvutil"
|
||||
)
|
||||
|
||||
// GCGCharData 角色卡牌配置表
|
||||
type GCGCharData struct {
|
||||
CharId int32 `csv:"CharId"` // ID
|
||||
TagId1 int32 `csv:"TagId1,omitempty"` // 卡牌标签列表1
|
||||
TagId2 int32 `csv:"TagId2,omitempty"` // 卡牌标签列表2
|
||||
TagId3 int32 `csv:"TagId3,omitempty"` // 卡牌标签列表3
|
||||
TagId4 int32 `csv:"TagId4,omitempty"` // 卡牌标签列表4
|
||||
TagId5 int32 `csv:"TagId5,omitempty"` // 卡牌标签列表5
|
||||
SkillListStr string `csv:"SkillListStr,omitempty"` // 卡牌技能列表文本
|
||||
HPBase int32 `csv:"HPBase,omitempty"` // 角色生命值
|
||||
MaxElemVal int32 `csv:"MaxElemVal,omitempty"` // 角色充能上限
|
||||
CharId int32 `csv:"ID"`
|
||||
TagId1 int32 `csv:"[卡牌标签列表]1,omitempty"`
|
||||
TagId2 int32 `csv:"[卡牌标签列表]2,omitempty"`
|
||||
TagId3 int32 `csv:"[卡牌标签列表]3,omitempty"`
|
||||
TagId4 int32 `csv:"[卡牌标签列表]4,omitempty"`
|
||||
TagId5 int32 `csv:"[卡牌标签列表]5,omitempty"`
|
||||
SkillList IntArray `csv:"卡牌技能列表,omitempty"`
|
||||
HPBase int32 `csv:"角色生命值,omitempty"`
|
||||
MaxElemVal int32 `csv:"角色充能上限,omitempty"`
|
||||
|
||||
TagList []uint32 // 卡牌标签列表
|
||||
SkillList []uint32 // 卡牌技能列表
|
||||
TagList []uint32 // 卡牌标签列表
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadGCGCharData() {
|
||||
g.GCGCharDataMap = make(map[int32]*GCGCharData)
|
||||
data := g.readCsvFileData("GCGCharData.csv")
|
||||
var gcgCharDataList []*GCGCharData
|
||||
err := csvutil.Unmarshal(data, &gcgCharDataList)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("parse file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
gcgCharDataList := make([]*GCGCharData, 0)
|
||||
readTable[GCGCharData](g.tablePrefix+"GCGCharData.txt", &gcgCharDataList)
|
||||
for _, gcgCharData := range gcgCharDataList {
|
||||
// 将TagId整合进TagList
|
||||
gcgCharData.TagList = make([]uint32, 0, 5)
|
||||
@@ -47,17 +35,6 @@ func (g *GameDataConfig) loadGCGCharData() {
|
||||
}
|
||||
gcgCharData.TagList = append(gcgCharData.TagList, uint32(tagId))
|
||||
}
|
||||
// 技能列表读取转换
|
||||
tempSkillList := strings.Split(strings.ReplaceAll(gcgCharData.SkillListStr, " ", ""), "#")
|
||||
gcgCharData.SkillList = make([]uint32, 0, len(tempSkillList))
|
||||
for _, s := range tempSkillList {
|
||||
skillId, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
logger.Error("skill id to i err, %v", err)
|
||||
return
|
||||
}
|
||||
gcgCharData.SkillList = append(gcgCharData.SkillList, uint32(skillId))
|
||||
}
|
||||
// list -> map
|
||||
g.GCGCharDataMap[gcgCharData.CharId] = gcgCharData
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user