refactor: 将物品和货币相关字段从uint32改为int64以支持更大数值范围
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -53,6 +53,6 @@ type GlowFilter struct {
|
||||
// ItemInfo
|
||||
// 用于表示发放物品的信息
|
||||
type ItemInfo struct {
|
||||
ItemId uint32 `json:"itemId" description:"发放物品ID"` // 发放物品ID,
|
||||
ItemCnt uint32 `json:"itemCount" description:"发放物品的数量"` // 发放物品的数量,
|
||||
ItemId int64 `struc:"uint32"`
|
||||
ItemCnt int64 `struc:"uint32"`
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)})
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ import (
|
||||
// 对应原 C# 的 C2S_EGG_GAME_PLAY
|
||||
type C2S_EGG_GAME_PLAY struct {
|
||||
Head common.TomeeHeader `cmd:"3201" struc:"skip"`
|
||||
EggNum int32 `struc:"uint32"` // 抽蛋次数标识:1 = 1次 2 = 5次 3 = 10次
|
||||
EggNum int64 `struc:"uint32"` // 抽蛋次数标识:1 = 1次 2 = 5次 3 = 10次
|
||||
// 注:Go 中 uint 是平台相关类型(32/64位),游戏开发中推荐用 uint32 明确匹配 C# 的 uint
|
||||
}
|
||||
|
||||
// S2C_EGG_GAME_PLAY 后端向前端返回的抽蛋结果结构体
|
||||
// 对应原 C# 的 S2C_EGG_GAME_PLAY
|
||||
type S2C_EGG_GAME_PLAY struct {
|
||||
GiftIN uint32 `json:"giftIN"` // 未知字段 写0 未引用
|
||||
PetID uint32 `json:"petID"` // 抽中精灵的id
|
||||
HadTime uint32 `json:"hadTime"` // 抽中精灵的捕捉时间(若为时间戳,建议改为 uint64)
|
||||
GiftIN uint32 `struc:"uint32"`
|
||||
PetID uint32 `struc:"uint32"` // 抽中精灵的id
|
||||
HadTime uint32 `struc:"uint32"` // 抽中精灵的捕捉时间(若为时间戳,建议改为 uint64)
|
||||
ListInfoLen uint32 `struc:"sizeof=ListInfo"`
|
||||
ListInfo []data.ItemInfo `json:"listinfo"` // 抽中物品的物品数组
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import "blazing/common/data"
|
||||
type S2C_GET_BOSS_MONSTER struct {
|
||||
BonusID uint32 // 激活前端任务的ID
|
||||
EXP uint32 `json:"exp" description:"奖励经验"`
|
||||
EV uint32 `json:"ev" description:"奖励累计学习力"`
|
||||
EV int64 `struc:"uint32"`
|
||||
PetID uint32 // 发放精灵的ID
|
||||
CaptureTm uint32 // 发放精灵的捕获时间
|
||||
ItemListLen uint32 `struc:"sizeof=ItemList"`
|
||||
|
||||
@@ -5,17 +5,17 @@ import "blazing/logic/service/common"
|
||||
type BuyInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2601" struc:"skip"`
|
||||
//物品ID
|
||||
ItemId uint32
|
||||
ItemId int64 `struc:"uint32"`
|
||||
//物品数量
|
||||
Count uint32
|
||||
Count int64 `struc:"uint32"`
|
||||
}
|
||||
type BuyOutboundInfo struct {
|
||||
//剩余的数量
|
||||
Coins uint32
|
||||
Coins int64 `struc:"uint32"`
|
||||
//购买的物品ID
|
||||
ItemId uint32
|
||||
ItemId int64 `struc:"uint32"`
|
||||
//购买数量
|
||||
Count uint32
|
||||
Count int64 `struc:"uint32"`
|
||||
//购买的物品等级
|
||||
Level uint32
|
||||
}
|
||||
@@ -26,7 +26,7 @@ type BuyMultiInboundInfo struct {
|
||||
}
|
||||
type BuyMultiOutboundInfo struct {
|
||||
//剩余的数量
|
||||
Coins uint32
|
||||
Coins int64 `struc:"uint32"`
|
||||
}
|
||||
|
||||
// C2S_GOLD_BUY_PRODUCT 客户端→服务端:金豆购买商品请求
|
||||
@@ -34,7 +34,7 @@ type C2S_GOLD_BUY_PRODUCT struct {
|
||||
Head common.TomeeHeader `cmd:"1104" struc:"skip"`
|
||||
Type uint32 `json:"type"` //购买类型,0是豆子购买,1是金豆购买
|
||||
ProductID uint32 `json:"product_id"` // 金豆物品id对应的产品id
|
||||
Count uint32 `json:"count"` // 购买数量(前端限制金豆物品只能1个1个买)
|
||||
Count int64 `struc:"uint32"` // 购买数量(前端限制金豆物品只能1个1个买)
|
||||
}
|
||||
|
||||
// S2C_GoldBuyProductInfo 服务端→客户端:金豆购买商品结果返回
|
||||
|
||||
@@ -29,7 +29,7 @@ type GoldOnlineRemainInboundInfo struct {
|
||||
type GoldOnlineRemainOutboundInfo struct {
|
||||
// GoldNumber 金豆数量(后端返回实际数量需要*100)
|
||||
GoldNumber uint32 `json:"goldNumber" `
|
||||
Coin uint32
|
||||
Coin int64 `struc:"uint32"`
|
||||
}
|
||||
|
||||
// ExpTotalRemainInboundInfo 累计经验相关的入站信息
|
||||
|
||||
@@ -20,6 +20,6 @@ type DayTalkInfo struct {
|
||||
}
|
||||
type CateInfo struct {
|
||||
// 示例字段,需替换为实际定义
|
||||
ID uint32
|
||||
ID int64 `struc:"uint32"`
|
||||
Count uint32
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ type PetSetExpInboundInfo struct {
|
||||
CatchTime uint32 `fieldDescription:"精灵获取时间" uint:"true" autoCodec:"true"`
|
||||
|
||||
// Exp 分配经验,对应Java的@UInt long
|
||||
Exp uint32 `fieldDescription:"分配经验" uint:"true" autoCodec:"true"`
|
||||
Exp int64 `struc:"uint32"`
|
||||
}
|
||||
|
||||
// 实现OutboundMessage接口,用于处理宠物设置经验的出站消息
|
||||
type PetSetExpOutboundInfo struct {
|
||||
// Exp 剩余累计经验,对应Java的@UInt long
|
||||
Exp uint32 `fieldDescription:"剩余累计经验" uint:"true" autoCodec:"true"`
|
||||
Exp int64 `struc:"uint32"`
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func (p *Player) GenMonster() {
|
||||
}
|
||||
if ok {
|
||||
|
||||
p.OgreInfo.Data[i].Item = uint32(mapss.Monsters.ItemBonusID)
|
||||
p.OgreInfo.Data[i].Item = int64(mapss.Monsters.ItemBonusID)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,20 @@ import (
|
||||
)
|
||||
|
||||
// AddPetExp 添加宠物经验
|
||||
func (p *Player) AddPetExp(petInfo *model.PetInfo, addExp uint32) {
|
||||
func (p *Player) AddPetExp(petInfo *model.PetInfo, addExp int64) {
|
||||
if addExp < 0 {
|
||||
return
|
||||
}
|
||||
addExp = utils.Min(addExp, p.Info.ExpPool)
|
||||
originalLevel := petInfo.Level
|
||||
exp := petInfo.Exp + addExp
|
||||
exp := int64(petInfo.Exp) + addExp
|
||||
p.Info.ExpPool -= addExp //减去已使用的经验
|
||||
gainedExp := exp //已获得的经验
|
||||
for exp >= petInfo.NextLvExp {
|
||||
for exp >= int64(petInfo.NextLvExp) {
|
||||
|
||||
petInfo.Level++
|
||||
|
||||
exp -= petInfo.LvExp
|
||||
exp -= int64(petInfo.LvExp)
|
||||
petInfo.Update(true)
|
||||
if originalLevel < 100 && petInfo.Level == 100 { //升到100了
|
||||
p.Info.ExpPool += exp //减去已使用的经验
|
||||
@@ -32,7 +35,7 @@ func (p *Player) AddPetExp(petInfo *model.PetInfo, addExp uint32) {
|
||||
}
|
||||
|
||||
}
|
||||
petInfo.Exp = exp
|
||||
petInfo.Exp = (exp)
|
||||
// 重新计算面板
|
||||
if originalLevel != petInfo.Level {
|
||||
petInfo.CalculatePetPane(false)
|
||||
@@ -67,7 +70,7 @@ func (p *Player) AddPetExp(petInfo *model.PetInfo, addExp uint32) {
|
||||
var petUpdateInfo info.UpdatePropInfo
|
||||
|
||||
copier.Copy(&petUpdateInfo, petInfo)
|
||||
petUpdateInfo.Exp = gainedExp
|
||||
petUpdateInfo.Exp = uint32(gainedExp)
|
||||
updateOutbound.Data = append(updateOutbound.Data, petUpdateInfo)
|
||||
p.SendPack(header.Pack(updateOutbound)) //准备包由各自发,因为协议不一样
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ type OgrePetInfo struct {
|
||||
ShinyLen uint32 `json:"-" struc:"sizeof=ShinyInfo"`
|
||||
ShinyInfo []data.GlowFilter `json:"ShinyInfo,omitempty"`
|
||||
Lv uint32 `struc:"skip"` //等级
|
||||
Item uint32 `struc:"skip"` //奖励,如果有的话
|
||||
Item int64 `struc:"skip"` //奖励,如果有的话
|
||||
Ext uint32 `struc:"skip"` //是否变尼尔尼奥
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ func WithConn(c gnet.Conn) PlayerOption {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Player) GetCoins(amount uint32) bool {
|
||||
if p.Info.Coins < amount {
|
||||
func (p *Player) GetCoins(amount int64) bool {
|
||||
if int64(p.Info.Coins) < amount {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -187,7 +187,13 @@ func (p *Player) SendPack(b []byte) error {
|
||||
}
|
||||
|
||||
// 添加物品 返回成功添加的物品
|
||||
func (p *Player) ItemAdd(ItemId, ItemCnt uint32) (result bool) {
|
||||
func (p *Player) ItemAdd(ItemId, ItemCnt int64) (result bool) {
|
||||
if ItemCnt <= 0 {
|
||||
t1 := common.NewTomeeHeader(2601, p.Info.UserID)
|
||||
t1.Result = uint32(errorcode.ErrorCodes.ErrSystemError200007)
|
||||
|
||||
p.SendPack(t1.Pack(nil)) //准备包由各自发,因为协议不一样
|
||||
}
|
||||
switch ItemId {
|
||||
case 1: //塞尔豆
|
||||
p.Info.Coins = p.Info.Coins + ItemCnt
|
||||
@@ -215,7 +221,7 @@ func (p *Player) ItemAdd(ItemId, ItemCnt uint32) (result bool) {
|
||||
|
||||
}
|
||||
|
||||
if p.Service.Item.CheakItem(ItemId)+int32(ItemCnt) > int32(itemmax) {
|
||||
if p.Service.Item.CheakItem(uint32(ItemId))+int64(ItemCnt) > int64(itemmax) {
|
||||
|
||||
println(p.Info.UserID, "物品超过拥有最大限制", ItemId)
|
||||
t1 := common.NewTomeeHeader(2601, p.Info.UserID)
|
||||
@@ -224,7 +230,7 @@ func (p *Player) ItemAdd(ItemId, ItemCnt uint32) (result bool) {
|
||||
p.SendPack(t1.Pack(nil)) //准备包由各自发,因为协议不一样
|
||||
return false
|
||||
}
|
||||
p.Service.Item.UPDATE(ItemId, gconv.Int(ItemCnt))
|
||||
p.Service.Item.UPDATE(uint32(ItemId), gconv.Int(ItemCnt))
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ func (p *Player) Save() {
|
||||
|
||||
}
|
||||
|
||||
newtime := uint32(time.Now().Unix())
|
||||
p.Info.TimeToday = p.Info.TimeToday + newtime - uint32(p.Logintime) //保存电池时间
|
||||
newtime := time.Now().Unix()
|
||||
p.Info.TimeToday = p.Info.TimeToday + newtime - int64(p.Logintime) //保存电池时间
|
||||
|
||||
p.Info.OnlineTime = p.Info.OnlineTime + (newtime-uint32(p.Logintime))/60 //每次退出时候保存已经在线的分钟数
|
||||
p.Info.OnlineTime = p.Info.OnlineTime + (newtime-int64(p.Logintime))/60 //每次退出时候保存已经在线的分钟数
|
||||
if p.FightC != nil {
|
||||
|
||||
defer p.FightC.Over(p, info.BattleOverReason.PlayerOffline) //玩家逃跑,但是不能锁线程
|
||||
@@ -51,5 +51,5 @@ func (p *Player) CanGetExp() bool {
|
||||
|
||||
ttt := p.Info.TimeLimit - p.Info.TimeToday
|
||||
|
||||
return (uint32(time.Now().Unix()) - uint32(p.Logintime)) <= ttt
|
||||
return (int64(time.Now().Unix()) - int64(p.Logintime)) <= ttt
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type C2S_BUY_FITMENT struct {
|
||||
}
|
||||
type S2C_BUY_FITMENT struct {
|
||||
// Coins 购买后剩余的赛尔豆(对应前端 coins 字段)
|
||||
Coins uint32 `json:"coins"`
|
||||
Coins int64 `struc:"uint32"`
|
||||
// ID 购买的物品ID(对应前端 id 字段,即家具ID)
|
||||
ID uint32 `json:"id"`
|
||||
// Count 字段说明:前端未调用该参数,推测为购买数量(与C2S的count对应)
|
||||
|
||||
@@ -22,8 +22,8 @@ type S2C_GET_GIFT_COMPLETE struct {
|
||||
|
||||
// GiftInfo 礼品信息
|
||||
type GiftInfo struct {
|
||||
GiftID uint32 `json:"giftID"` // 就是物品id
|
||||
Count uint32 `json:"count"`
|
||||
GiftID int64 `struc:"uint32"`
|
||||
Count int64 `struc:"uint32"`
|
||||
}
|
||||
type PetGiftInfo struct {
|
||||
PetID uint32 `json:"petID"`
|
||||
|
||||
@@ -24,7 +24,7 @@ type ChangeColorOutboundInfo struct {
|
||||
UserId uint32 `codec:"userId"` // 更改人的用户id (对应Java的@UInt long)
|
||||
Color uint32 `codec:"color"` // 前端发来的更改的颜色rgb值 (对应Java的@UInt long)
|
||||
Texture uint32 `codec:"texture"` // 大概是当前的涂装 by 7 (对应Java的@UInt long)
|
||||
Coins uint32 `codec:"coins"` // 扣除200豆子后返回的剩余豆子 (对应Java的@UInt long)
|
||||
Coins int64 `struc:"uint32"`
|
||||
}
|
||||
type ChangeDoodleInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2062" struc:"skip"`
|
||||
@@ -36,7 +36,7 @@ type ChangeDoodleOutboundInfo struct {
|
||||
UserId uint32 `codec:"userId"` // 更改人的userid (对应Java的@UInt long)
|
||||
Color uint32 `codec:"color"` // 使用前端发的id 从itemInfo中获得 (对应Java的@UInt long)
|
||||
Texture uint32 `codec:"texture"` // 使用前端发的id 从itemInfo中获得 (对应Java的@UInt long)
|
||||
Coins uint32 `codec:"coins"` // 扣除对应豆子后返回的剩余豆子 (对应Java的@UInt long)
|
||||
Coins int64 `struc:"uint32"`
|
||||
}
|
||||
type ChangeNONOColorInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"9012" struc:"skip"`
|
||||
|
||||
@@ -14,12 +14,12 @@ type ItemGift struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段,保持与现有模型一致性)
|
||||
|
||||
// 核心业务字段(按需求实现:物品id、备注、是否启用、是否为扭蛋、物品数量)
|
||||
ItemID uint32 `gorm:"not null;default:0;comment:'物品ID,关联物品配置表主键'" json:"item_id"`
|
||||
ItemID int64 `gorm:"not null;default:0;comment:'物品ID,关联物品配置表主键'" json:"item_id"`
|
||||
Remark string `gorm:"size:512;default:'';comment:'物品奖励备注说明(如使用场景、特殊说明等)'" json:"remark"`
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用(0-禁用 1-启用)'" json:"is_enabled"`
|
||||
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
//ItemCount uint32 `gorm:"not null;default:1;comment:'物品奖励数量'" json:"item_count"`
|
||||
ItemMinCount uint32 `gorm:"column:item_min_count;not null;comment:单次采集最小产出数量" json:"item_min_count"`
|
||||
ItemMinCount int64 `gorm:"column:item_min_count;not null;comment:单次采集最小产出数量" json:"item_min_count"`
|
||||
// ItemMaxCount 单次采集最大产出数量
|
||||
ItemMaxCount uint32 `gorm:"column:item_max_count;not null;comment:单次采集最大产出数量" json:"item_max_count"`
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ type ShopConfig struct {
|
||||
// 核心字段
|
||||
ProductName string `gorm:"not null;size:128;comment:'商品名称'" json:"product_name" description:"商品名称"`
|
||||
//商品ID
|
||||
ProductID uint32 `gorm:"not null;uniqueIndex;comment:'商品ID'" json:"product_id" description:"商品ID"`
|
||||
ProductID int64 `gorm:"not null;uniqueIndex;comment:'商品ID'" json:"product_id" description:"商品ID"`
|
||||
Desc string `gorm:"not null;size:512;comment:'商品描述'" json:"desc" description:"商品描述"`
|
||||
|
||||
// 价格信息 -1代表不允许购买,0表示不支持购买
|
||||
|
||||
@@ -29,12 +29,12 @@ func (s *ItemService) GetItemCount(id uint32) data.ItemInfo {
|
||||
res.ItemCnt = item.ItemMinCount
|
||||
|
||||
if item.ItemMaxCount != 0 {
|
||||
res.ItemCnt = uint32(grand.N(int(item.ItemMinCount), int(item.ItemMaxCount)))
|
||||
res.ItemCnt = int64(grand.N(int(item.ItemMinCount), int(item.ItemMaxCount)))
|
||||
|
||||
}
|
||||
return res
|
||||
}
|
||||
func (s *ItemService) GetEgg(count int32) []data.ItemInfo {
|
||||
func (s *ItemService) GetEgg(count int64) []data.ItemInfo {
|
||||
var item []model.ItemGift
|
||||
cool.DBM(s.Model).Where("is_egg", 1).Where("is_enabled", 1).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
@@ -46,7 +46,7 @@ func (s *ItemService) GetEgg(count int32) []data.ItemInfo {
|
||||
var res = make([]data.ItemInfo, len(rr))
|
||||
for _, v := range rr {
|
||||
if v.ItemMaxCount != 0 {
|
||||
v.ItemMinCount = uint32(grand.N(int(v.ItemMinCount), int(v.ItemMaxCount)))
|
||||
v.ItemMinCount = int64(grand.N(int(v.ItemMinCount), int(v.ItemMaxCount)))
|
||||
|
||||
}
|
||||
res = append(res, data.ItemInfo{ItemId: v.ItemID, ItemCnt: v.ItemMinCount})
|
||||
|
||||
@@ -90,7 +90,7 @@ func (s *DictInfoService) GetData(types string) (data map[uint32]model.DictInfo)
|
||||
}
|
||||
|
||||
// 获取物品的最大数限制
|
||||
func (s *DictInfoService) GetMax(value uint32) (max uint32) {
|
||||
func (s *DictInfoService) GetMax(value int64) (max uint32) {
|
||||
|
||||
m := cool.DBM(s.Model)
|
||||
var ress *model.DictInfo
|
||||
|
||||
@@ -119,9 +119,9 @@ func (m *PlayerInfo) GetTask(i int) TaskStatus {
|
||||
}
|
||||
|
||||
type PlayerInfo struct {
|
||||
ExpPool uint32 `struc:"skip" json:"exp_pool"` // 累计经验池
|
||||
ExpPool int64 `struc:"skip" json:"exp_pool"` // 累计经验池
|
||||
|
||||
OnlineTime uint32 `struc:"skip" json:"online_time"` //在线分钟数
|
||||
OnlineTime int64 `struc:"skip" json:"online_time"` //在线分钟数
|
||||
// OutInfo 字段
|
||||
UserID uint32 `struc:"uint32" json:"user_id"` // 米米号 通过sid拿到
|
||||
RegisterTime uint32 `struc:"uint32" json:"register_time"` // 注册时间(秒时间戳)
|
||||
@@ -133,13 +133,13 @@ type PlayerInfo struct {
|
||||
Color uint32 `struc:"uint32" json:"color"` // 机器人颜色RGB颜色值(uint32,实际为3个uint8)
|
||||
Texture uint32 `struc:"uint32" json:"texture"` // 固定0
|
||||
Energy uint32 `struc:"uint32" default:"3000" json:"energy"` // 固定3000
|
||||
Coins uint32 `struc:"uint32" json:"coins"` // 赛尔豆
|
||||
EVPool uint32 `struc:"uint32" json:"ev_pool"` //累计学习力
|
||||
Coins int64 `struc:"uint32" json:"coins"` // 赛尔豆
|
||||
EVPool int64 `struc:"uint32" json:"ev_pool"` //累计学习力
|
||||
FightBadge uint32 `struc:"uint32" json:"fight_badge"` // 固定0
|
||||
MapID uint32 `struc:"uint32" default:"1" json:"map_id"` // 上线地图ID
|
||||
Pos Pos `json:"pos"` // 坐标
|
||||
TimeToday uint32 `struc:"uint32" default:"0" json:"time_today"` // 已消耗时间(秒)
|
||||
TimeLimit uint32 `struc:"uint32" default:"43200" json:"time_limit"` // 总电池限制(秒)
|
||||
TimeToday int64 `struc:"uint32" default:"0" json:"time_today"` // 已消耗时间(秒)
|
||||
TimeLimit int64 `struc:"uint32" default:"43200" json:"time_limit"` // 总电池限制(秒)
|
||||
IsClothHalfDay byte `struc:"byte" json:"is_cloth_half_day"` // 活动标志0/1
|
||||
IsRoomHalfDay byte `struc:"byte" json:"is_room_half_day"` // 活动标志0/1
|
||||
IFortressHalfDay byte `struc:"byte" json:"i_fortress_half_day"` // 活动标志0/1
|
||||
|
||||
@@ -15,7 +15,7 @@ type Item struct {
|
||||
BindPet uint32 `json:"bind_pet"` //绑定的精灵
|
||||
|
||||
// 物品数量,
|
||||
ItemCnt int32 `json:"item_cnt"`
|
||||
ItemCnt int64 `json:"item_cnt"`
|
||||
}
|
||||
|
||||
type SingleItemInfo struct {
|
||||
|
||||
@@ -65,13 +65,13 @@ type PetInfo struct {
|
||||
Level uint32 `fieldDesc:"等级" `
|
||||
|
||||
// 当前等级已获得经验(@UInt long → uint32)
|
||||
Exp uint32
|
||||
Exp int64 `struc:"uint32"`
|
||||
|
||||
// 当前等级所需经验(@UInt long → uint32)
|
||||
LvExp uint32
|
||||
LvExp int64 `struc:"uint32"`
|
||||
|
||||
// 升到下一级的经验(@UInt long → uint32)
|
||||
NextLvExp uint32
|
||||
NextLvExp int64 `struc:"uint32"`
|
||||
|
||||
// 当前生命(@UInt long → uint32)
|
||||
Hp uint32
|
||||
@@ -128,7 +128,7 @@ const (
|
||||
// 功能:为宠物6个EV值增加增量,保证单个≤255、总和≤510
|
||||
// 参数:evadd - 6个EV字段的增量数组(长度必须为6)
|
||||
// 返回:error - 参数非法/逻辑异常时返回错误;bool - 是否触发了超额削减(方便业务监控)
|
||||
func (pet *PetInfo) AddEV(ev_add []uint32) (bool, error) {
|
||||
func (pet *PetInfo) AddEV(ev_add []int64) (bool, error) {
|
||||
// 1. 参数安全校验:避免数组越界panic
|
||||
if len(ev_add) != evFieldCount {
|
||||
return false, fmt.Errorf("evadd长度必须为%d,当前为%d", evFieldCount, len(ev_add))
|
||||
@@ -141,7 +141,7 @@ func (pet *PetInfo) AddEV(ev_add []uint32) (bool, error) {
|
||||
var tempEV [evFieldCount]uint32
|
||||
for i := 0; i < evFieldCount; i++ {
|
||||
// 直接累加增量
|
||||
tempEV[i] = pet.Ev[i] + ev_add[i]
|
||||
tempEV[i] = pet.Ev[i] + uint32(ev_add[i])
|
||||
// 单项不超过255
|
||||
if tempEV[i] > maxSingleEV {
|
||||
tempEV[i] = maxSingleEV
|
||||
@@ -342,7 +342,7 @@ func (petinfo *PetInfo) Update(isup bool) {
|
||||
// calculateExperience 计算指定等级和种族值所需的经验值
|
||||
// level: 当前等级
|
||||
// baseValue: 种族值
|
||||
func calculateExperience(level uint32, baseValue uint32) uint32 {
|
||||
func calculateExperience(level uint32, baseValue uint32) int64 {
|
||||
// 计算 A 部分:向上取整(3.75 * a * (a + 1))
|
||||
partA := math.Ceil(3.75 * float64(level) * float64(level+1))
|
||||
|
||||
@@ -354,7 +354,7 @@ func calculateExperience(level uint32, baseValue uint32) uint32 {
|
||||
|
||||
// 总经验是两部分之和,并向上取整
|
||||
totalExp := math.Ceil(partA + partB)
|
||||
return uint32(totalExp)
|
||||
return int64(totalExp)
|
||||
}
|
||||
|
||||
// PetEffectInfo 精灵特性信息结构
|
||||
|
||||
@@ -45,7 +45,7 @@ func (s *ItemService) UPDATE(id uint32, count int) {
|
||||
|
||||
}
|
||||
|
||||
func (s *ItemService) CheakItem(id uint32) int32 {
|
||||
func (s *ItemService) CheakItem(id uint32) int64 {
|
||||
var ttt model.Item
|
||||
m := s.TestModel(s.Model)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user