Files
bl/logic/controller/item_sale.go
xinian 6510e4e09b
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor: 重构入参类型引用
2026-04-05 07:24:36 +08:00

28 lines
814 B
Go

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