Files
bl/logic/controller/action_egg.go
昔念 026689f3ed ```
feat(cache): 添加复合键缓存操作支持

添加了基于 uint32+string 组合键的缓存操作方法,包括
GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和
ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景

fix(vscode): 添加 cSpell 配置支持 struc 词汇

refactor(session): 移除过时的会话管理方法

移除了基于单一字符串键的会话管理方法,因为已迁移到使用
复合键的缓存操作方式
```
2026-01-19 18:51:56 +08:00

54 lines
1.3 KiB
Go

package controller
import (
"blazing/common/data"
"blazing/common/socket/errorcode"
"blazing/logic/service/egg"
"blazing/logic/service/player"
"blazing/modules/config/service"
"blazing/modules/player/model"
"github.com/gogf/gf/v2/util/grand"
)
func (h Controller) EggGamePlay(data1 *egg.C2S_EGG_GAME_PLAY, c *player.Player) (result *egg.S2C_EGG_GAME_PLAY, err errorcode.ErrorCode) {
switch data1.EggNum {
case 2:
data1.EggNum = 5
case 3:
data1.EggNum = 10
}
r := c.Service.Item.CheakItem(400501)
if r < data1.EggNum {
return nil, errorcode.ErrorCode(errorcode.ErrorCodes.ErrSystemError)
}
result = &egg.S2C_EGG_GAME_PLAY{ListInfo: []data.ItemInfo{}}
if grand.Meet(int(data1.EggNum), 100) {
r := service.NewPetRewardService().GetEgg()
newPet := model.GenPetInfo(int(r.MonID), int(r.DV), int(r.Nature), int(r.Effect), int(r.Lv), nil)
if grand.Meet(int(data1.EggNum), 100) {
newPet.RandShiny()
}
c.Service.Pet.PetAdd(newPet)
result.HadTime = newPet.CatchTime
result.PetID = newPet.ID
}
items := service.NewItemService().GetEgg(data1.EggNum)
for _, item := range items {
if item.ItemId == 0 {
continue
}
c.ItemAdd(item.ItemId, item.ItemCnt)
result.ListInfo = append(result.ListInfo, data.ItemInfo{ItemId: item.ItemId, ItemCnt: item.ItemCnt})
}
c.Service.Item.UPDATE(400501, int(-data1.EggNum))
return
}