feat(element): 优化元素计算器并发安全与缓存机制

- 使用 sync.Map 替代 map+锁,提升并发读写性能
- 预加载所有元素组合,避免运行时重复创建
- 攻击系数计算结果加入缓存,提高查询效率
- 完善缓存键命名与错误处理机制
- 调整元素组合字符串展示格式,增强可读性

fix(item): 修复购买物品时价格为0仍扣除金币的问题

- 在购买逻辑中增加对物品价格是否为0的判断
- 防止免费物品被误扣金币
This commit is contained in:
2025-11-02 23:52:06 +08:00
parent 038bd0ce0c
commit 7a8be1c23a
13 changed files with 1051 additions and 263 deletions

View File

@@ -0,0 +1,16 @@
package xmlres
// Root 对应 XML 根节点 <root>
type ShopRoot struct {
Items []ShopItem `xml:"item"` // 所有 <item> 子节点映射为 Items 切片
}
// Item 对应 XML 中的 <item> 节点
type ShopItem struct {
ItemID string `xml:"itemID,attr"` // 物品ID属性
Name string `xml:"name,attr"` // 物品名称(属性)
ProductID string `xml:"productID,attr"` // 商品ID属性可能为空
Price int `xml:"price,attr"` // 金豆价格(属性,整数)
Vip float64 `xml:"vip,attr"` // VIP折扣属性小数
MoneyType string `xml:"moneyType,attr"` // 货币类型属性部分item可能缺失
}