refactor: 将物品和货币相关字段从uint32改为int64以支持更大数值范围
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-02-12 04:28:20 +08:00
committed by cnb
parent b5feb85792
commit d0cf598ced
29 changed files with 92 additions and 85 deletions

View File

@@ -204,7 +204,7 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
EXP: exp * 2,
}
if refPet.Item != 0 {
count := uint32(grand.Intn(2) + 1)
count := int64(grand.Intn(2) + 1)
p.ItemAdd(refPet.Item, count)
items.ItemList = append(items.ItemList, data.ItemInfo{
ItemId: refPet.Item,
@@ -213,13 +213,13 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
}
evs := gconv.Uint32s(strings.Split(xmlres.PetMAP[int(monster.ID)].YieldingEV, " "))
evs := gconv.Int64s(strings.Split(xmlres.PetMAP[int(monster.ID)].YieldingEV, " "))
items.EV = lo.Sum(evs) - 1
p.Info.EVPool += lo.Sum(evs) //给予累计学习力
foi.Winpet.AddEV(evs)
p.Info.ExpPool += exp * 4
p.AddPetExp(foi.Winpet, uint32(exp)*2)
p.Info.ExpPool += int64(exp) * 4
p.AddPetExp(foi.Winpet, int64((exp)*2))
p.SendPackCmd(8004, items)
}

View File

@@ -7,8 +7,6 @@ import (
"blazing/logic/service/item"
"blazing/logic/service/player"
"github.com/gogf/gf/v2/util/gconv"
)
// 防止封包通过领取来获取道具
@@ -37,7 +35,7 @@ func (h Controller) BuyItem(data *item.BuyInboundInfo, player *player.Player) (r
}
// 需要付费的道具
totalCost := data.Count * uint32(itemInfo.Price)
totalCost := int64(data.Count) * int64(itemInfo.Price)
if !player.GetCoins(totalCost) {
return &item.BuyOutboundInfo{Coins: player.Info.Coins}, errorcode.ErrorCodes.ErrSunDouInsufficient10016
}
@@ -70,17 +68,17 @@ func (h Controller) BuyMultipleItems(data *item.BuyMultiInboundInfo, player *pla
// 免费道具直接添加
if itemInfo.Price == 0 {
player.ItemAdd(itemID, 1)
player.ItemAdd(int64(itemID), 1)
continue
}
// 需要付费的道具
if !player.GetCoins(uint32(itemInfo.Price)) {
if !player.GetCoins(int64(itemInfo.Price)) {
break
}
if player.ItemAdd(itemID, 1) {
player.Info.Coins -= uint32(itemInfo.Price)
if player.ItemAdd(int64(itemID), 1) {
player.Info.Coins -= int64(itemInfo.Price)
}
}
@@ -107,7 +105,7 @@ func (h Controller) BuyGoldItem(data *item.C2S_GOLD_BUY_PRODUCT, player *player.
return nil, errorcode.ErrorCodes.ErrSystemError
}
if !player.GetCoins(data.Count * uint32(pro.SeerdouPrice)) {
if !player.GetCoins(data.Count * int64(pro.SeerdouPrice)) {
return nil, errorcode.ErrorCodes.ErrSystemError
}
usegold = uint64(data.Count) * uint64(pro.SeerdouPrice)
@@ -124,12 +122,12 @@ func (h Controller) BuyGoldItem(data *item.C2S_GOLD_BUY_PRODUCT, player *player.
}
addSuccess = player.ItemAdd(uint32(gconv.Uint32(pro.ProductID)), uint32(data.Count))
addSuccess = player.ItemAdd(pro.ProductID, data.Count)
if addSuccess {
switch data.Type {
case 0:
player.Info.Coins -= uint32(usegold)
player.Info.Coins -= int64(usegold)
case 1:
player.User.UpdateGold(player.Info.UserID, -int64(usegold))

View File

@@ -15,13 +15,13 @@ import (
// 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) < int32(data.Amount) {
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 += uint32(int64(data.Amount) * int64(itemConfig.SellPrice))
c.Info.Coins += int64(int64(data.Amount) * int64(itemConfig.SellPrice))
}
c.Service.Item.UPDATE(data.ItemId, -gconv.Int(data.Amount))
return result, 0

View File

@@ -28,7 +28,7 @@ func (h Controller) PetELV(data *pet.C2S_PET_EVOLVTION, c *player.Player) (resul
}
evinfo := xmlres.EVOLVMAP[flag].Branches[data.Index-1]
if c.Service.Item.CheakItem(uint32(evinfo.EvolvItem)) < int32(evinfo.EvolvItemCount) {
if c.Service.Item.CheakItem(uint32(evinfo.EvolvItem)) < int64(evinfo.EvolvItemCount) {
return nil, errorcode.ErrorCodes.ErrInsufficientItemsMulti
}
if evinfo.EvolvItem != 0 {

View File

@@ -38,12 +38,12 @@ func (h Controller) PetEVDiy(data *pet.PetEV, c *player.Player) (result *pet.S2C
usedEV := lo.Sum(data.EVs[:]) - lo.Sum(currentPet.Ev[:])
// 加的比池子还多
if usedEV > c.Info.EVPool {
if int64(usedEV) > c.Info.EVPool {
return nil, errorcode.ErrorCodes.Err10401
}
currentPet.Ev = data.EVs
currentPet.CalculatePetPane(false)
c.Info.EVPool -= usedEV
c.Info.EVPool -= int64(usedEV)
result = &pet.S2C_50001{}
result.UseEV = usedEV

View File

@@ -15,13 +15,13 @@ func (h Controller) BuyFitment(data *room.C2S_BUY_FITMENT, c *player.Player) (re
result = &room.S2C_BUY_FITMENT{}
itemConfig := xmlres.ItemsMAP[int(data.ID)]
totalCost := itemConfig.Price * int(data.Count)
totalCost := int64(itemConfig.Price) * int64(data.Count)
if !c.GetCoins(uint32(totalCost)) {
if !c.GetCoins((totalCost)) {
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
}
c.Service.Item.UPDATE(data.ID, int(data.Count))
c.Info.Coins -= uint32(totalCost)
c.Info.Coins -= int64(totalCost)
result.ID = data.ID
result.Coins = c.Info.Coins
return

View File

@@ -35,7 +35,7 @@ func (h Controller) GetTalkCategory(data *item.TalkCateInboundInfo, c *player.Pl
for _, itemID := range config.ItemIDS {
iteminfo := service.NewItemService().GetItemCount(itemID)
success := c.ItemAdd(uint32(iteminfo.ItemId), uint32(iteminfo.ItemCnt))
success := c.ItemAdd(iteminfo.ItemId, iteminfo.ItemCnt)
if success {
result.OutList = append(result.OutList, item.CateInfo{ID: iteminfo.ItemId, Count: uint32(iteminfo.ItemCnt)})