refactor(blazing): 重构任务系统并优化相关功能

- 重构了任务系统的数据结构和执行逻辑
- 优化了地图加载和怪物刷新机制
- 改进了宠物系统的基础架构
- 调整了玩家信息和背包的处理方式
- 统一了数据访问层的接口和实现
This commit is contained in:
2025-08-30 21:59:52 +08:00
parent 2ed5c2db27
commit 75e428f62e
23 changed files with 326 additions and 230 deletions

View File

@@ -1,6 +1,7 @@
package xmlres
import (
"blazing/common/utils"
"os"
"github.com/ECUST-XX/xml"
@@ -23,11 +24,13 @@ func getXml[T any](path string) T {
}
var (
MapConfig Maps //地图配置
ItemsConfig Items //物品配置
TalkConfig TalkCount //任务配置
Monster MonsterRoot //野怪配置
Skill MovesTbl //技能配置
MapConfig Maps //地图配置
ItemsConfig Items //物品配置
TalkConfig TalkCount //任务配置
//Monster MonsterRoot //野怪配置
MonsterMap map[int]TMapConfig
//Skill MovesTbl //技能配置
SkillMap map[int]Move
)
func initfile() {
@@ -36,8 +39,18 @@ func initfile() {
MapConfig = getXml[Maps](path + "210.xml")
ItemsConfig = getXml[Items](path + "43.xml")
TalkConfig = getXml[TalkCount](path + "talk.xml")
Monster = getXml[MonsterRoot](path + "地图配置野怪.xml")
Skill = getXml[MovesTbl](path + "227.xml")
Monster := getXml[MonsterRoot](path + "地图配置野怪.xml")
MonsterMap = utils.ToMap(Monster.Maps, func(m TMapConfig) int {
return m.ID
})
Skill := getXml[MovesTbl](path + "227.xml")
SkillMap = utils.ToMap[Move, int](Skill.Moves, func(m Move) int {
return m.ID
})
}

View File

@@ -4,7 +4,6 @@ import (
"encoding/xml"
"fmt"
"io"
"log"
"net/http"
"time"
)
@@ -87,31 +86,3 @@ func ReadHTTPFile(url string) ([]byte, error) {
return content, nil
}
func getxml() ([]byte, error) {
// 读取整个文件内容,返回字节切片和错误
content, err := ReadHTTPFile("http://127.0.0.1:8080/assets/227.xml")
if err != nil {
// 处理错误(文件不存在、权限问题等)
log.Fatalf("无法读取文件: %v", err)
}
return content, nil
}
func getMoves() MovesMap {
// 解析XML到结构体
var maps MovesTbl
t1, _ := getxml()
xml.Unmarshal(t1, &maps)
var mapss MovesMap
mapss.Moves = make(map[int]Move, 0)
for _, v := range maps.Moves {
mapss.Moves[int(v.ID)] = v
}
return mapss
}
// 全局函数配置
var MovesConfig = getMoves()