feat(item): 优化购买金币商品逻辑并完善宠物属性计算

- 购买金币商品时增加失败回滚机制,确保扣除金币与实际获得物品一致
- 使用 `CalculatePetPane` 替代 `Update` 方法以正确刷新宠物面板数据
- 精简地图热度统计逻辑,移除并发安全库依赖,改用普通 map 配合原子操作
- 移除 Space 结构体中冗余的 SuperValue 字段,直接通过 map 统计地图人数
- 更新地图配置文件中的怪物分布信息,调整部分怪物等级和数量配置
```
This commit is contained in:
2025-11-25 21:10:52 +08:00
parent 6455455992
commit f682abe537
8 changed files with 36 additions and 52 deletions

View File

@@ -61,9 +61,11 @@ func (h Controller) BuyGoldItem(data *item.C2S_GOLD_BUY_PRODUCT, c *player.Playe
if !c.UseGold(uint32(data.Count) * uint32(gconv.Uint32(r.Price))) {
return nil, errorcode.ErrorCodes.ErrSystemError
}
c.ItemAdd(model.ItemInfo{ItemId: uint32(gconv.Uint32(r.ItemID)), ItemCnt: uint32(data.Count)})
c.Info.GoldBean -= gconv.Uint32(r.Price)
r1 := c.ItemAdd(model.ItemInfo{ItemId: uint32(gconv.Uint32(r.ItemID)), ItemCnt: uint32(data.Count)})
if len(r1) == int(data.Count) {
//失败返还
c.Info.GoldBean += uint32(uint32(data.Count)-uint32(len(r1))) * uint32(gconv.Uint32(r.Price))
}
result = &item.S2C_GoldBuyProductInfo{
Gold: c.Info.GoldBean,
PayGold: uint32(data.Count) * uint32(gconv.Uint32(r.Price)),