Files
bl/logic/controller/item_sale.go

25 lines
711 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"
)
func (h Controller) ITEM_SALE(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
}
if xmlres.ItemsMAP[int(data.ItemId)].SellPrice != 0 {
c.Info.Coins += uint32(int64(data.Amount) * int64(xmlres.ItemsMAP[int(data.ItemId)].SellPrice))
}
c.Service.Item.UPDATE(data.ItemId, -gconv.Int(data.Amount))
return result, 0
}