Files
bl/logic/controller/item_sale.go
昔念 502d497dce ```
refactor(controller): 重构控制器函数命名和代码注释

- 重命名 EGG 函数为 EggGamePlay,更新宠物生成逻辑
- 重命名 Leiyi 函数为 GetLeiyiTrainStatus
- 重命名 Cacthpet 函数为 CatchPet,添加详细函数注释
- 为 ArenaSetOwner、ArenaFightOwner、ArenaGetInfo、ArenaUpfight、ArenaOwnerAcce
  等擂台相关函数添加注释前缀
- 重命名 PETKing 函数为 PetKing
- 重命名 FRESH_CHOICE_FIGHT_LEVEL 函数为 FreshChoiceFightLevel,添加详细参数说明
- 重命名 BuyMItem 函数为 BuyMultipleItems
- 重命名 ITEM_S
2025-12-24 19:03:11 +08:00

29 lines
843 B
Go

package controller
import (
"blazing/common/data/xmlres"
"blazing/common/socket/errorcode"
"blazing/logic/service/fight"
"blazing/logic/service/item"
"blazing/logic/service/player"
"github.com/gogf/gf/v2/util/gconv"
)
// ItemSale 出售道具
// data: 包含道具ID和数量的输入信息
// c: 当前玩家对象
// 返回: 空结果和错误码
func (h Controller) ItemSale(data *item.C2S_ITEM_SALE, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if c.Service.Item.CheakItem(data.ItemId) < data.Amount {
return nil, errorcode.ErrorCodes.ErrSystemError
}
itemConfig := xmlres.ItemsMAP[int(data.ItemId)]
if itemConfig.SellPrice != 0 {
c.Info.Coins += uint32(int64(data.Amount) * int64(itemConfig.SellPrice))
}
c.Service.Item.UPDATE(data.ItemId, -gconv.Int(data.Amount))
return result, 0
}