格式化代码

This commit is contained in:
huangxiaolei
2022-12-19 13:40:04 +08:00
parent f773ba8df7
commit 58b2df2bc6
92 changed files with 682 additions and 626 deletions

View File

@@ -2,11 +2,13 @@ package gdconf
import (
"fmt"
"github.com/hjson/hjson-go/v4"
"github.com/jszwec/csvutil"
"os"
"hk4e/pkg/endec"
"hk4e/pkg/logger"
"os"
"github.com/hjson/hjson-go/v4"
"github.com/jszwec/csvutil"
)
// 角色配置表
@@ -58,7 +60,7 @@ func (g *GameDataConfig) loadAvatarData() {
panic(info)
}
if len(configAvatar.Abilities) == 0 {
logger.LOG.Info("can not find any ability of avatar, AvatarId: %v", avatarData.AvatarId)
logger.Info("can not find any ability of avatar, AvatarId: %v", avatarData.AvatarId)
}
for _, configAvatarAbility := range configAvatar.Abilities {
abilityHashCode := endec.Hk4eAbilityHashCode(configAvatarAbility.AbilityName)
@@ -67,5 +69,5 @@ func (g *GameDataConfig) loadAvatarData() {
// list -> map
g.AvatarDataMap[avatarData.AvatarId] = avatarData
}
logger.LOG.Info("AvatarData count: %v", len(g.AvatarDataMap))
logger.Info("AvatarData count: %v", len(g.AvatarDataMap))
}

View File

@@ -2,8 +2,10 @@ package gdconf
import (
"fmt"
"github.com/jszwec/csvutil"
"hk4e/pkg/logger"
"github.com/jszwec/csvutil"
)
// 角色技能配置表
@@ -29,5 +31,5 @@ func (g *GameDataConfig) loadAvatarSkillData() {
// list -> map
g.AvatarSkillDataMap[avatarSkillData.AvatarSkillId] = avatarSkillData
}
logger.LOG.Info("AvatarSkillData count: %v", len(g.AvatarSkillDataMap))
logger.Info("AvatarSkillData count: %v", len(g.AvatarSkillDataMap))
}

View File

@@ -2,8 +2,10 @@ package gdconf
import (
"fmt"
"github.com/jszwec/csvutil"
"hk4e/pkg/logger"
"github.com/jszwec/csvutil"
)
// 角色技能库配置表
@@ -94,5 +96,5 @@ func (g *GameDataConfig) loadAvatarSkillDepotData() {
// list -> map
g.AvatarSkillDepotDataMap[avatarSkillDepotData.AvatarSkillDepotId] = avatarSkillDepotData
}
logger.LOG.Info("AvatarSkillDepotData count: %v", len(g.AvatarSkillDepotDataMap))
logger.Info("AvatarSkillDepotData count: %v", len(g.AvatarSkillDepotDataMap))
}

View File

@@ -1,19 +1,21 @@
package gdconf
import (
"github.com/hjson/hjson-go/v4"
"hk4e/common/config"
"hk4e/pkg/logger"
"os"
"strings"
"testing"
"time"
"hk4e/common/config"
"hk4e/pkg/logger"
"github.com/hjson/hjson-go/v4"
)
func CheckJsonLoop(path string, errorJsonFileList *[]string, totalJsonFileCount *int) {
fileList, err := os.ReadDir(path)
if err != nil {
logger.LOG.Error("open dir error: %v", err)
logger.Error("open dir error: %v", err)
return
}
for _, file := range fileList {
@@ -26,7 +28,7 @@ func CheckJsonLoop(path string, errorJsonFileList *[]string, totalJsonFileCount
}
fileData, err := os.ReadFile(path + "/" + fileName)
if err != nil {
logger.LOG.Error("open file error: %v", err)
logger.Error("open file error: %v", err)
continue
}
var obj any
@@ -45,8 +47,8 @@ func TestCheckJsonValid(t *testing.T) {
totalJsonFileCount := 0
CheckJsonLoop("./game_data_config/json", &errorJsonFileList, &totalJsonFileCount)
for _, v := range errorJsonFileList {
logger.LOG.Info("%v", v)
logger.Info("%v", v)
}
logger.LOG.Info("err json file count: %v, total count: %v", len(errorJsonFileList), totalJsonFileCount)
logger.Info("err json file count: %v, total count: %v", len(errorJsonFileList), totalJsonFileCount)
time.Sleep(time.Second)
}

View File

@@ -1,8 +1,9 @@
package gdconf
import (
"github.com/jszwec/csvutil"
"hk4e/pkg/logger"
"github.com/jszwec/csvutil"
)
type Drop struct {
@@ -26,7 +27,7 @@ func (g *GameDataConfig) loadDropGroupData() {
var dropList []*Drop
err := csvutil.Unmarshal(data, &dropList)
if err != nil {
logger.LOG.Error("parse file error: %v", err)
logger.Error("parse file error: %v", err)
return
}
for _, drop := range dropList {
@@ -42,5 +43,5 @@ func (g *GameDataConfig) loadDropGroupData() {
dropGroupData.DropConfig = append(dropGroupData.DropConfig, drop)
}
}
logger.LOG.Info("load %v DropGroupData", len(g.DropGroupDataMap))
logger.Info("load %v DropGroupData", len(g.DropGroupDataMap))
}

View File

@@ -2,9 +2,10 @@ package gdconf
import (
"fmt"
"hk4e/common/config"
"os"
"strings"
"hk4e/common/config"
)
// 游戏数据配置表

View File

@@ -1,17 +1,18 @@
package gdconf
import (
"hk4e/common/config"
"hk4e/pkg/logger"
"testing"
"time"
"hk4e/common/config"
"hk4e/pkg/logger"
)
func TestInitGameDataConfig(t *testing.T) {
config.InitConfig("./application.toml")
logger.InitLogger("test")
logger.LOG.Info("start load conf")
logger.Info("start load conf")
InitGameDataConfig()
logger.LOG.Info("load conf finish, conf: %v", CONF)
logger.Info("load conf finish, conf: %v", CONF)
time.Sleep(time.Second)
}