mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-16 22:12:27 +08:00
简化配置表读取
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user