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

@@ -49,6 +49,9 @@ var (
PlayerEffectMAP map[int]NewSeIdx
ItemsMAP map[int]Item
TaskMap map[int]Task
ShopMap map[int]ShopItem
SkillTypeMap map[int]SkillType
RelationsMap map[int]Relation
)
func initfile() {
@@ -75,7 +78,12 @@ func initfile() {
return m.ID
})
Shop1 := getXml[ShopRoot](path + "地图配置野怪.xml")
ShopMap = utils.ToMap(Shop1.Items, func(m ShopItem) int {
return gconv.Int(m.ProductID)
})
Skill := getXml[MovesTbl](path + "227.xml")
SkillMap = make(map[int]Move, len(Skill.Moves))