mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 15:52:27 +08:00
任务接取、进度、完成状态
This commit is contained in:
@@ -51,6 +51,7 @@ type GameDataConfig struct {
|
||||
ReliquaryMainDataMap map[int32]map[int32]*ReliquaryMainData // 圣遗物主属性
|
||||
ReliquaryAffixDataMap map[int32]map[int32]*ReliquaryAffixData // 圣遗物追加属性
|
||||
QuestDataMap map[int32]*QuestData // 任务
|
||||
TriggerDataMap map[int32]*TriggerData // 场景LUA触发器
|
||||
}
|
||||
|
||||
func InitGameDataConfig() {
|
||||
@@ -137,6 +138,7 @@ func (g *GameDataConfig) load() {
|
||||
g.loadReliquaryMainData() // 圣遗物主属性
|
||||
g.loadReliquaryAffixData() // 圣遗物追加属性
|
||||
g.loadQuestData() // 任务
|
||||
g.loadTriggerData() // 场景LUA触发器
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) readCsvFileData(fileName string) []byte {
|
||||
|
||||
@@ -2,10 +2,10 @@ package gdconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hk4e/common/constant"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"hk4e/common/constant"
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"github.com/jszwec/csvutil"
|
||||
|
||||
@@ -8,6 +8,13 @@ import (
|
||||
"github.com/jszwec/csvutil"
|
||||
)
|
||||
|
||||
type QuestCond struct {
|
||||
Type int32
|
||||
Param []int32
|
||||
ComplexParam string
|
||||
Count int32
|
||||
}
|
||||
|
||||
// QuestData 任务配置表
|
||||
type QuestData struct {
|
||||
QuestId int32 `csv:"QuestId"` // ID
|
||||
@@ -61,26 +68,131 @@ type QuestData struct {
|
||||
FailCondType3Param2 int32 `csv:"FailCondType3Param2,omitempty"` // [失败条件]3参数2
|
||||
FailCondType3ComplexParam string `csv:"FailCondType3ComplexParam,omitempty"` // [失败条件]3复杂参数
|
||||
FailCondType3Count int32 `csv:"FailCondType3Count,omitempty"` // [失败条件]3次数
|
||||
|
||||
AcceptCondList []*QuestCond // 领取条件
|
||||
FinishCondList []*QuestCond // 完成条件
|
||||
FailCondList []*QuestCond // 失败条件
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadQuestData() {
|
||||
g.QuestDataMap = make(map[int32]*QuestData)
|
||||
data := g.readCsvFileData("QuestData.csv")
|
||||
var questDataList []*QuestData
|
||||
err := csvutil.Unmarshal(data, &questDataList)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("parse file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
for _, questData := range questDataList {
|
||||
// list -> map
|
||||
g.QuestDataMap[questData.QuestId] = questData
|
||||
fileNameList := []string{"QuestData.csv", "QuestData_Exported.csv"}
|
||||
for _, fileName := range fileNameList {
|
||||
data := g.readCsvFileData(fileName)
|
||||
var questDataList []*QuestData
|
||||
err := csvutil.Unmarshal(data, &questDataList)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("parse file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
for _, questData := range questDataList {
|
||||
// list -> map
|
||||
// 领取条件
|
||||
questData.AcceptCondList = make([]*QuestCond, 0)
|
||||
if questData.AcceptCondType1 != 0 {
|
||||
paramList := make([]int32, 0)
|
||||
if questData.AcceptCondType1Param1 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType1Param1)
|
||||
}
|
||||
if questData.AcceptCondType1Param2 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType1Param2)
|
||||
}
|
||||
if questData.AcceptCondType1Param3 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType1Param3)
|
||||
}
|
||||
questData.AcceptCondList = append(questData.AcceptCondList, &QuestCond{
|
||||
Type: questData.AcceptCondType1,
|
||||
Param: paramList,
|
||||
})
|
||||
}
|
||||
if questData.AcceptCondType2 != 0 {
|
||||
paramList := make([]int32, 0)
|
||||
if questData.AcceptCondType2Param1 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType2Param1)
|
||||
}
|
||||
if questData.AcceptCondType2Param2 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType2Param2)
|
||||
}
|
||||
if questData.AcceptCondType2Param3 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType2Param3)
|
||||
}
|
||||
questData.AcceptCondList = append(questData.AcceptCondList, &QuestCond{
|
||||
Type: questData.AcceptCondType2,
|
||||
Param: paramList,
|
||||
})
|
||||
}
|
||||
if questData.AcceptCondType3 != 0 {
|
||||
paramList := make([]int32, 0)
|
||||
if questData.AcceptCondType3Param1 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType3Param1)
|
||||
}
|
||||
if questData.AcceptCondType3Param2 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType3Param2)
|
||||
}
|
||||
if questData.AcceptCondType3Param3 != 0 {
|
||||
paramList = append(paramList, questData.AcceptCondType3Param3)
|
||||
}
|
||||
questData.AcceptCondList = append(questData.AcceptCondList, &QuestCond{
|
||||
Type: questData.AcceptCondType3,
|
||||
Param: paramList,
|
||||
})
|
||||
}
|
||||
// 完成条件
|
||||
questData.FinishCondList = make([]*QuestCond, 0)
|
||||
if questData.FinishCondType1 != 0 {
|
||||
paramList := make([]int32, 0)
|
||||
if questData.FinishCondType1Param1 != 0 {
|
||||
paramList = append(paramList, questData.FinishCondType1Param1)
|
||||
}
|
||||
if questData.FinishCondType1Param2 != 0 {
|
||||
paramList = append(paramList, questData.FinishCondType1Param2)
|
||||
}
|
||||
questData.FinishCondList = append(questData.FinishCondList, &QuestCond{
|
||||
Type: questData.FinishCondType1,
|
||||
Param: paramList,
|
||||
ComplexParam: questData.FinishCondType1ComplexParam,
|
||||
Count: questData.FinishCondType1Count,
|
||||
})
|
||||
}
|
||||
if questData.FinishCondType2 != 0 {
|
||||
paramList := make([]int32, 0)
|
||||
if questData.FinishCondType2Param1 != 0 {
|
||||
paramList = append(paramList, questData.FinishCondType2Param1)
|
||||
}
|
||||
if questData.FinishCondType2Param2 != 0 {
|
||||
paramList = append(paramList, questData.FinishCondType2Param2)
|
||||
}
|
||||
questData.FinishCondList = append(questData.FinishCondList, &QuestCond{
|
||||
Type: questData.FinishCondType2,
|
||||
Param: paramList,
|
||||
ComplexParam: questData.FinishCondType2ComplexParam,
|
||||
Count: questData.FinishCondType2Count,
|
||||
})
|
||||
}
|
||||
if questData.FinishCondType3 != 0 {
|
||||
paramList := make([]int32, 0)
|
||||
if questData.FinishCondType3Param1 != 0 {
|
||||
paramList = append(paramList, questData.FinishCondType3Param1)
|
||||
}
|
||||
if questData.FinishCondType3Param2 != 0 {
|
||||
paramList = append(paramList, questData.FinishCondType3Param2)
|
||||
}
|
||||
questData.FinishCondList = append(questData.FinishCondList, &QuestCond{
|
||||
Type: questData.FinishCondType3,
|
||||
Param: paramList,
|
||||
ComplexParam: questData.FinishCondType3ComplexParam,
|
||||
Count: questData.FinishCondType3Count,
|
||||
})
|
||||
}
|
||||
// 失败条件
|
||||
g.QuestDataMap[questData.QuestId] = questData
|
||||
}
|
||||
}
|
||||
logger.Info("QuestData count: %v", len(g.QuestDataMap))
|
||||
}
|
||||
|
||||
func GetQuestDataById(sceneId int32) *QuestData {
|
||||
return CONF.QuestDataMap[sceneId]
|
||||
func GetQuestDataById(questId int32) *QuestData {
|
||||
return CONF.QuestDataMap[questId]
|
||||
}
|
||||
|
||||
func GetQuestDataMap() map[int32]*QuestData {
|
||||
|
||||
@@ -1263,5 +1263,275 @@
|
||||
"origin_name": "[失败条件]3次数"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "QuestData_Exported",
|
||||
"field_list": [
|
||||
{
|
||||
"field_name": "QuestId",
|
||||
"field_type": "int32",
|
||||
"origin_name": "子任务ID"
|
||||
},
|
||||
{
|
||||
"field_name": "ParentQuestId",
|
||||
"field_type": "int32",
|
||||
"origin_name": "父任务ID"
|
||||
},
|
||||
{
|
||||
"field_name": "Sequence",
|
||||
"field_type": "int32",
|
||||
"origin_name": "序列"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondCompose",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]组合"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]1类型"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType1Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]1参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType1Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]1参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType1Param3",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]1参数3"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]2类型"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType2Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]2参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType2Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]2参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType2Param3",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]2参数3"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType3",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]3类型"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType3Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]3参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType3Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]3参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "AcceptCondType3Param3",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[领取条件]3参数3"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondCompose",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]组合"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]1类型"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType1Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]1参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType1Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]1参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType1ComplexParam",
|
||||
"field_type": "string",
|
||||
"origin_name": "[完成条件]1复杂参数"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType1Count",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]1次数"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]2类型"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType2Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]2参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType2Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]2参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType2ComplexParam",
|
||||
"field_type": "string",
|
||||
"origin_name": "[完成条件]2复杂参数"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType2Count",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]2次数"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType3",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]3类型"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType3Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]3参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType3Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]3参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType3ComplexParam",
|
||||
"field_type": "string",
|
||||
"origin_name": "[完成条件]3复杂参数"
|
||||
},
|
||||
{
|
||||
"field_name": "FinishCondType3Count",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[完成条件]3次数"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondCompose",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]组合"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]1类型"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType1Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]1参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType1Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]1参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType1ComplexParam",
|
||||
"field_type": "string",
|
||||
"origin_name": "[失败条件]1复杂参数"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType1Count",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]1次数"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]2类型"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType2Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]2参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType2Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]2参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType2ComplexParam",
|
||||
"field_type": "string",
|
||||
"origin_name": "[失败条件]2复杂参数"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType2Count",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]2次数"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType3",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]3类型"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType3Param1",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]3参数1"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType3Param2",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]3参数2"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType3ComplexParam",
|
||||
"field_type": "string",
|
||||
"origin_name": "[失败条件]3复杂参数"
|
||||
},
|
||||
{
|
||||
"field_name": "FailCondType3Count",
|
||||
"field_type": "int32",
|
||||
"origin_name": "[失败条件]3次数"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"table_name": "TriggerData",
|
||||
"field_list": [
|
||||
{
|
||||
"field_name": "TriggerId",
|
||||
"field_type": "int32",
|
||||
"origin_name": "ID"
|
||||
},
|
||||
{
|
||||
"field_name": "SceneId",
|
||||
"field_type": "int32",
|
||||
"origin_name": "场景ID"
|
||||
},
|
||||
{
|
||||
"field_name": "GroupId",
|
||||
"field_type": "int32",
|
||||
"origin_name": "组ID"
|
||||
},
|
||||
{
|
||||
"field_name": "TriggerName",
|
||||
"field_type": "string",
|
||||
"origin_name": "触发器"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
40
gdconf/trigger_data.go
Normal file
40
gdconf/trigger_data.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package gdconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"github.com/jszwec/csvutil"
|
||||
)
|
||||
|
||||
// TriggerData 场景LUA触发器配置表
|
||||
type TriggerData struct {
|
||||
TriggerId int32 `csv:"TriggerId"` // ID
|
||||
SceneId int32 `csv:"SceneId,omitempty"` // 场景ID
|
||||
GroupId int32 `csv:"GroupId,omitempty"` // 组ID
|
||||
TriggerName string `csv:"TriggerName,omitempty"` // 触发器
|
||||
}
|
||||
|
||||
func (g *GameDataConfig) loadTriggerData() {
|
||||
g.TriggerDataMap = make(map[int32]*TriggerData)
|
||||
data := g.readCsvFileData("TriggerData.csv")
|
||||
var triggerDataList []*TriggerData
|
||||
err := csvutil.Unmarshal(data, &triggerDataList)
|
||||
if err != nil {
|
||||
info := fmt.Sprintf("parse file error: %v", err)
|
||||
panic(info)
|
||||
}
|
||||
for _, triggerData := range triggerDataList {
|
||||
g.TriggerDataMap[triggerData.TriggerId] = triggerData
|
||||
}
|
||||
logger.Info("TriggerData count: %v", len(g.TriggerDataMap))
|
||||
}
|
||||
|
||||
func GetTriggerDataById(triggerId int32) *TriggerData {
|
||||
return CONF.TriggerDataMap[triggerId]
|
||||
}
|
||||
|
||||
func GetTriggerDataMap() map[int32]*TriggerData {
|
||||
return CONF.TriggerDataMap
|
||||
}
|
||||
Reference in New Issue
Block a user