简化配置表读取

This commit is contained in:
flswld
2023-03-16 16:26:14 +08:00
parent 2a3ce25898
commit 5e5492943d
51 changed files with 418 additions and 2560 deletions

View File

@@ -1,34 +1,25 @@
package gdconf
import (
"fmt"
"hk4e/pkg/logger"
"github.com/jszwec/csvutil"
)
// WeaponLevelData 武器等级配置表
type WeaponLevelData struct {
Level int32 `csv:"Level"` // 等级
ExpByStar1 int32 `csv:"ExpByStar1,omitempty"` // 武器升级经验1
ExpByStar2 int32 `csv:"ExpByStar2,omitempty"` // 武器升级经验2
ExpByStar3 int32 `csv:"ExpByStar3,omitempty"` // 武器升级经验3
ExpByStar4 int32 `csv:"ExpByStar4,omitempty"` // 武器升级经验4
ExpByStar5 int32 `csv:"ExpByStar5,omitempty"` // 武器升级经验5
Level int32 `csv:"等级"`
ExpByStar1 int32 `csv:"武器升级经验1,omitempty"`
ExpByStar2 int32 `csv:"武器升级经验2,omitempty"`
ExpByStar3 int32 `csv:"武器升级经验3,omitempty"`
ExpByStar4 int32 `csv:"武器升级经验4,omitempty"`
ExpByStar5 int32 `csv:"武器升级经验5,omitempty"`
ExpByStarMap map[uint32]uint32 // 星级对应武器升级经验
}
func (g *GameDataConfig) loadWeaponLevelData() {
g.WeaponLevelDataMap = make(map[int32]*WeaponLevelData)
data := g.readCsvFileData("WeaponLevelData.csv")
var weaponLevelDataList []*WeaponLevelData
err := csvutil.Unmarshal(data, &weaponLevelDataList)
if err != nil {
info := fmt.Sprintf("parse file error: %v", err)
panic(info)
}
weaponLevelDataList := make([]*WeaponLevelData, 0)
readTable[WeaponLevelData](g.tablePrefix+"WeaponLevelData.txt", &weaponLevelDataList)
for _, weaponLevelData := range weaponLevelDataList {
// list -> map
weaponLevelData.ExpByStarMap = map[uint32]uint32{