package controller import ( "blazing/common/data/xmlres" "blazing/common/socket/errorcode" "blazing/logic/service/player" ) func buySeerdouBackpackItem(player *player.Player, itemID int64, count int64) (bought bool, err errorcode.ErrorCode) { if itemID <= 0 || count <= 0 { return false, errorcode.ErrorCodes.ErrSystemError } itemInfo, exists := xmlres.ItemsMAP[int(itemID)] if !exists { return false, 0 } totalCost := int64(itemInfo.Price) * count if totalCost > 0 && !player.GetCoins(totalCost) { return false, errorcode.ErrorCodes.ErrSunDouInsufficient10016 } if !player.ItemAdd(itemID, count) { return false, 0 } player.Info.Coins -= totalCost return true, 0 }