mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
圣遗物追加词条初步
This commit is contained in:
@@ -24,31 +24,32 @@ type GameDataConfig struct {
|
||||
jsonPrefix string
|
||||
luaPrefix string
|
||||
// 配置表数据
|
||||
AvatarDataMap map[int32]*AvatarData // 角色
|
||||
AvatarSkillDataMap map[int32]*AvatarSkillData // 角色技能
|
||||
AvatarSkillDepotDataMap map[int32]*AvatarSkillDepotData // 角色技能库
|
||||
DropGroupDataMap map[int32]*DropGroupData // 掉落组
|
||||
GCGCharDataMap map[int32]*GCGCharData // 角色卡牌
|
||||
GCGSkillDataMap map[int32]*GCGSkillData // 卡牌技能
|
||||
SceneDataMap map[int32]*SceneData // 场景
|
||||
ScenePointMap map[int32]*ScenePoint // 场景传送点
|
||||
SceneTagDataMap map[int32]*SceneTagData // 场景标签
|
||||
SceneDetailMap map[int32]*SceneDetail // 场景详情LUA配置数据
|
||||
WorldAreaDataMap map[int32]*WorldAreaData // 世界区域
|
||||
GatherDataMap map[int32]*GatherData // 采集物
|
||||
GatherDataPointTypeMap map[int32]*GatherData // 采集物场景节点索引
|
||||
FetterDataMap map[int32]*FetterData // 角色资料解锁
|
||||
FetterDataAvatarIdMap map[int32][]int32 // 角色资料解锁角色id索引
|
||||
ItemDataMap map[int32]*ItemData // 统一道具
|
||||
AvatarLevelDataMap map[int32]*AvatarLevelData // 角色等级
|
||||
AvatarPromoteDataMap map[int32]map[int32]*AvatarPromoteData // 角色突破
|
||||
PlayerLevelDataMap map[int32]*PlayerLevelData // 玩家等级
|
||||
WeaponLevelDataMap map[int32]*WeaponLevelData // 武器等级
|
||||
WeaponPromoteDataMap map[int32]map[int32]*WeaponPromoteData // 角色突破
|
||||
RewardDataMap map[int32]*RewardData // 奖励
|
||||
AvatarCostumeDataMap map[int32]*AvatarCostumeData // 角色时装
|
||||
AvatarFlycloakDataMap map[int32]*AvatarFlycloakData // 角色风之翼
|
||||
ReliquaryMainDataMap map[int32]map[int32]*ReliquaryMainData // 圣遗物主属性
|
||||
AvatarDataMap map[int32]*AvatarData // 角色
|
||||
AvatarSkillDataMap map[int32]*AvatarSkillData // 角色技能
|
||||
AvatarSkillDepotDataMap map[int32]*AvatarSkillDepotData // 角色技能库
|
||||
DropGroupDataMap map[int32]*DropGroupData // 掉落组
|
||||
GCGCharDataMap map[int32]*GCGCharData // 角色卡牌
|
||||
GCGSkillDataMap map[int32]*GCGSkillData // 卡牌技能
|
||||
SceneDataMap map[int32]*SceneData // 场景
|
||||
ScenePointMap map[int32]*ScenePoint // 场景传送点
|
||||
SceneTagDataMap map[int32]*SceneTagData // 场景标签
|
||||
SceneDetailMap map[int32]*SceneDetail // 场景详情LUA配置数据
|
||||
WorldAreaDataMap map[int32]*WorldAreaData // 世界区域
|
||||
GatherDataMap map[int32]*GatherData // 采集物
|
||||
GatherDataPointTypeMap map[int32]*GatherData // 采集物场景节点索引
|
||||
FetterDataMap map[int32]*FetterData // 角色资料解锁
|
||||
FetterDataAvatarIdMap map[int32][]int32 // 角色资料解锁角色id索引
|
||||
ItemDataMap map[int32]*ItemData // 统一道具
|
||||
AvatarLevelDataMap map[int32]*AvatarLevelData // 角色等级
|
||||
AvatarPromoteDataMap map[int32]map[int32]*AvatarPromoteData // 角色突破
|
||||
PlayerLevelDataMap map[int32]*PlayerLevelData // 玩家等级
|
||||
WeaponLevelDataMap map[int32]*WeaponLevelData // 武器等级
|
||||
WeaponPromoteDataMap map[int32]map[int32]*WeaponPromoteData // 角色突破
|
||||
RewardDataMap map[int32]*RewardData // 奖励
|
||||
AvatarCostumeDataMap map[int32]*AvatarCostumeData // 角色时装
|
||||
AvatarFlycloakDataMap map[int32]*AvatarFlycloakData // 角色风之翼
|
||||
ReliquaryMainDataMap map[int32]map[int32]*ReliquaryMainData // 圣遗物主属性
|
||||
ReliquaryAffixDataMap map[int32]map[int32]*ReliquaryAffixData // 圣遗物追加属性
|
||||
}
|
||||
|
||||
func InitGameDataConfig() {
|
||||
@@ -72,7 +73,7 @@ func ReplaceGameDataConfig() {
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadAll() {
|
||||
pathPrefix := config.CONF.Hk4e.GameDataConfigPath
|
||||
pathPrefix := config.GetConfig().Hk4e.GameDataConfigPath
|
||||
|
||||
dirInfo, err := os.Stat(pathPrefix)
|
||||
if err != nil || !dirInfo.IsDir() {
|
||||
@@ -133,6 +134,7 @@ func (g *GameDataConfig) load() {
|
||||
g.loadAvatarCostumeData() // 角色时装
|
||||
g.loadAvatarFlycloakData() // 角色风之翼
|
||||
g.loadReliquaryMainData() // 圣遗物主属性
|
||||
g.loadReliquaryAffixData() // 圣遗物追加属性
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) readCsvFileData(fileName string) []byte {
|
||||
|
||||
@@ -38,6 +38,7 @@ type ItemData struct {
|
||||
ReliquaryType int32 `csv:"ReliquaryType,omitempty"` // 圣遗物类别
|
||||
MainPropDepotId int32 `csv:"MainPropDepotId,omitempty"` // 主属性库ID
|
||||
AppendPropDepotId int32 `csv:"AppendPropDepotId,omitempty"` // 追加属性库ID
|
||||
AppendPropCount int32 `csv:"AppendPropCount,omitempty"` // 追加属性初始条数
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadItemData() {
|
||||
|
||||
69
gdconf/reliquary_affix_data.go
Normal file
69
gdconf/reliquary_affix_data.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"github.com/jszwec/csvutil"
|
||||
"github.com/mroth/weightedrand"
|
||||
)
|
||||
|
||||
// ReliquaryAffixData 圣遗物追加属性配置表
|
||||
type ReliquaryAffixData struct {
|
||||
AppendPropId int32 `csv:"AppendPropId"` // 追加属性ID
|
||||
AppendPropDepotId int32 `csv:"AppendPropDepotId,omitempty"` // 追加属性库ID
|
||||
PropType int32 `csv:"PropType,omitempty"` // 属性类别
|
||||
RandomWeight int32 `csv:"RandomWeight,omitempty"` // 随机权重
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadReliquaryAffixData() {
|
||||
g.ReliquaryAffixDataMap = make(map[int32]map[int32]*ReliquaryAffixData)
|
||||
data := g.readCsvFileData("ReliquaryAffixData.csv")
|
||||
var reliquaryAffixDataList []*ReliquaryAffixData
|
||||
err := csvutil.Unmarshal(data, &reliquaryAffixDataList)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("parse file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
for _, reliquaryAffixData := range reliquaryAffixDataList {
|
||||
// 通过主属性库ID找到
|
||||
_, ok := g.ReliquaryAffixDataMap[reliquaryAffixData.AppendPropDepotId]
|
||||
if !ok {
|
||||
g.ReliquaryAffixDataMap[reliquaryAffixData.AppendPropDepotId] = make(map[int32]*ReliquaryAffixData)
|
||||
}
|
||||
// list -> map
|
||||
g.ReliquaryAffixDataMap[reliquaryAffixData.AppendPropDepotId][reliquaryAffixData.AppendPropId] = reliquaryAffixData
|
||||
}
|
||||
logger.Info("ReliquaryAffixData count: %v", len(g.ReliquaryAffixDataMap))
|
||||
}
|
||||
|
||||
func GetReliquaryAffixDataByDepotIdAndPropId(appendPropDepotId int32, appendPropId int32) *ReliquaryAffixData {
|
||||
value, exist := CONF.ReliquaryAffixDataMap[appendPropDepotId]
|
||||
if !exist {
|
||||
return nil
|
||||
}
|
||||
return value[appendPropId]
|
||||
}
|
||||
|
||||
func GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int32) *ReliquaryAffixData {
|
||||
appendPropMap, exist := CONF.ReliquaryAffixDataMap[appendPropDepotId]
|
||||
if !exist {
|
||||
return nil
|
||||
}
|
||||
choices := make([]weightedrand.Choice, 0, len(appendPropMap))
|
||||
for _, data := range appendPropMap {
|
||||
choices = append(choices, weightedrand.NewChoice(data, uint(data.RandomWeight)))
|
||||
}
|
||||
chooser, err := weightedrand.NewChooser(choices...)
|
||||
if err != nil {
|
||||
logger.Error("reliquary append random error: %v", err)
|
||||
return nil
|
||||
}
|
||||
result := chooser.Pick()
|
||||
return result.(*ReliquaryAffixData)
|
||||
}
|
||||
|
||||
func GetReliquaryAffixDataMap() map[int32]map[int32]*ReliquaryAffixData {
|
||||
return CONF.ReliquaryAffixDataMap
|
||||
}
|
||||
@@ -14,7 +14,7 @@ type ReliquaryMainData struct {
|
||||
MainPropId int32 `csv:"MainPropId"` // 主属性ID
|
||||
MainPropDepotId int32 `csv:"MainPropDepotId,omitempty"` // 主属性库ID
|
||||
PropType int32 `csv:"PropType,omitempty"` // 属性类别
|
||||
Weight int32 `csv:"Weight,omitempty"` // 随机权重
|
||||
RandomWeight int32 `csv:"RandomWeight,omitempty"` // 随机权重
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadReliquaryMainData() {
|
||||
@@ -53,11 +53,11 @@ func GetReliquaryMainDataRandomByDepotId(mainPropDepotId int32) *ReliquaryMainDa
|
||||
}
|
||||
choices := make([]weightedrand.Choice, 0, len(mainPropMap))
|
||||
for _, data := range mainPropMap {
|
||||
choices = append(choices, weightedrand.NewChoice(data, uint(data.Weight)))
|
||||
choices = append(choices, weightedrand.NewChoice(data, uint(data.RandomWeight)))
|
||||
}
|
||||
chooser, err := weightedrand.NewChooser(choices...)
|
||||
if err != nil {
|
||||
logger.Error("reliquary main error: %v", err)
|
||||
logger.Error("reliquary main random error: %v", err)
|
||||
return nil
|
||||
}
|
||||
result := chooser.Pick()
|
||||
|
||||
@@ -601,6 +601,11 @@
|
||||
"field_name": "AppendPropDepotId",
|
||||
"field_type": "int32",
|
||||
"origin_name": "追加属性库ID"
|
||||
},
|
||||
{
|
||||
"field_name": "AppendPropCount",
|
||||
"field_type": "int32",
|
||||
"origin_name": "追加属性初始条数"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -983,7 +988,32 @@
|
||||
"origin_name": "属性类别"
|
||||
},
|
||||
{
|
||||
"field_name": "Weight",
|
||||
"field_name": "RandomWeight",
|
||||
"field_type": "int32",
|
||||
"origin_name": "随机权重"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "ReliquaryAffixData",
|
||||
"field_list": [
|
||||
{
|
||||
"field_name": "AppendPropId",
|
||||
"field_type": "int32",
|
||||
"origin_name": "追加属性ID"
|
||||
},
|
||||
{
|
||||
"field_name": "AppendPropDepotId",
|
||||
"field_type": "int32",
|
||||
"origin_name": "追加属性库ID"
|
||||
},
|
||||
{
|
||||
"field_name": "PropType",
|
||||
"field_type": "int32",
|
||||
"origin_name": "属性类别"
|
||||
},
|
||||
{
|
||||
"field_name": "RandomWeight",
|
||||
"field_type": "int32",
|
||||
"origin_name": "随机权重"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user