feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
29 lines
818 B
Go
29 lines
818 B
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/data/xmlres"
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/logic/service/player"
|
|
"blazing/logic/service/room"
|
|
)
|
|
|
|
// BuyFitment 购买基地家具
|
|
// data: 包含家具ID和购买数量的输入信息
|
|
// c: 当前玩家对象
|
|
// 返回: 购买结果和错误码
|
|
func (h Controller) BuyFitment(data *room.C2S_BUY_FITMENT, c *player.Player) (result *room.S2C_BUY_FITMENT, err errorcode.ErrorCode) {
|
|
result = &room.S2C_BUY_FITMENT{}
|
|
|
|
itemConfig := xmlres.ItemsMAP[int(data.ID)]
|
|
totalCost := itemConfig.Price * int(data.Count)
|
|
|
|
if !c.GetCoins(uint32(totalCost)) {
|
|
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
|
}
|
|
c.Service.Item.UPDATE(data.ID, int(data.Count))
|
|
c.Info.Coins -= uint32(totalCost)
|
|
result.ID = data.ID
|
|
result.Coins = c.Info.Coins
|
|
return
|
|
}
|