feat(xmlres): 实装性格重塑,实装性格指定

fix(fight): 使用模型层方法生成精灵信息
refactor(controller): 移除冗余变量与内联XML读取逻辑
refactor(pet): 重构经验更新与进化逻辑
refactor(item): 校验并扣减使用道具数量
feat(item): 新增金豆购买商品协议结构体
feat(user): 迁移角色服装变更逻辑至user控制器
feat(pet): 增加技能排序协议定义
refactor(utils): 移除未使用的工具函数引用
chore(config): 更新地图怪物配置信息

详细变更内容包括:
- 在`xmlres/file.go`中初始化`GoldProductMap`并加载相关配置。
- 将`GenPetInfo`方法从玩家服务迁移至`model`包以统一管理。
- 合并部分不必要的局部变量声明,并优化XML资源加载方式。
- 拆分精灵升级与进化方法,明确调用职责。
- 在战斗和治疗等操作前增加货币校验及扣除逻辑。
- 补充金豆购买相关的客户端/服务端通信结构体。
- 调整技能选择逻辑避免潜在索引越界问题。
- 更新部分注释说明和代码结构以提升可维护性。
This commit is contained in:
2025-11-25 12:29:50 +08:00
parent 147758c5ae
commit 40d72790ff
23 changed files with 530 additions and 259 deletions

View File

@@ -52,6 +52,7 @@ var (
ShopMap map[int]ShopItem
SkillTypeMap map[int]SkillType
RelationsMap map[int]Relation
GoldProductMap = make(map[int]GoldProductItem, 0)
)
func initfile() {
@@ -72,15 +73,12 @@ func initfile() {
TalkConfig = getXml[TalkRoot](path + "talk.xml")
Monster := getXml[MonsterRoot](path + "地图配置野怪.xml")
MonsterMap = utils.ToMap(Monster.Maps, func(m TMapConfig) int {
MonsterMap = utils.ToMap(getXml[MonsterRoot](path+"地图配置野怪.xml").Maps, func(m TMapConfig) int {
return m.ID
})
Shop1 := getXml[ShopRoot](path + "地图配置野怪.xml")
ShopMap = utils.ToMap(Shop1.Items, func(m ShopItem) int {
ShopMap = utils.ToMap(getXml[ShopRoot](path+"地图配置野怪.xml").Items, func(m ShopItem) int {
return gconv.Int(m.ProductID)
})
@@ -92,19 +90,18 @@ func initfile() {
v.SideEffectArgS = ParseSideEffectArgs(v.SideEffectArg)
SkillMap[v.ID] = v
}
task := getXml[Tasks](path + "task.xml")
TaskMap = utils.ToMap[Task, int](task.Tasks, func(m Task) int {
TaskMap = utils.ToMap[Task, int](getXml[Tasks](path+"task.xml").Tasks, func(m Task) int {
return m.ID
})
pet := getXml[Monsters](path + "226.xml")
PetMAP = utils.ToMap[PetInfo, int](pet.Monsters, func(m PetInfo) int {
PetMAP = utils.ToMap[PetInfo, int](getXml[Monsters](path+"226.xml").Monsters, func(m PetInfo) int {
return m.ID
})
NatureRootMap1 := getXml[NatureRoot](path + "nature.xml")
NatureRootMap = utils.ToMap[NatureItem, int](NatureRootMap1.Items, func(m NatureItem) int {
NatureRootMap = utils.ToMap[NatureItem, int](getXml[NatureRoot](path+"nature.xml").Items, func(m NatureItem) int {
return m.ID
})
@@ -125,6 +122,13 @@ func initfile() {
}
GoldProductMap = utils.ToMap(getXml[GoldProductConfig](path+"30001.xml").Items,
func(m GoldProductItem) int {
return gconv.Int(m.ProductID)
},
)
}
func init() {

View File

@@ -0,0 +1,28 @@
package xmlres
import "github.com/ECUST-XX/xml"
// GoldProductConfig XML根节点结构体
type GoldProductConfig struct {
XMLName xml.Name `xml:"root"`
Items []GoldProductItem `xml:"item"` // 匹配所有<item>节点
}
// GoldProductItem 金豆商品配置项结构体
// 注xml标签为`xml:"属性名,attr"` 表示解析XML属性而非子节点
type GoldProductItem struct {
ItemID string `xml:"itemID,attr"` // 物品ID字符串先接收后续转uint
Name string `xml:"name,attr"` // 物品名称
ProductID string `xml:"productID,attr"` // 商品ID可选字段
Price string `xml:"price,attr"` // 金豆价格可选字段后续转float64
Vip string `xml:"vip,attr"` // VIP折扣可选字段后续转float64如0.6=6折
MoneyType string `xml:"moneyType,attr"` // 货币类型(可选字段)
Gold string `xml:"gold,attr"` // 赠送金豆数(可选字段)
// // 解析后的强类型字段(便于业务使用)
// ItemIDUint uint32 `xml:"-"` // 解析后的物品ID
// ProductIDUint uint32 `xml:"-"` // 解析后的商品ID
// PriceFloat float64 `xml:"-"` // 解析后的金豆价格
// VipFloat float64 `xml:"-"` // 解析后的VIP折扣
// MoneyTypeUint uint16 `xml:"-"` // 解析后的货币类型
// GoldUint uint32 `xml:"-"` // 解析后的赠送金豆数
}