feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
95 lines
3.0 KiB
Go
95 lines
3.0 KiB
Go
package controller
|
||
|
||
import (
|
||
"blazing/common/socket/errorcode"
|
||
"blazing/logic/service/fight"
|
||
"blazing/logic/service/pet"
|
||
"blazing/logic/service/player"
|
||
)
|
||
|
||
// GetBreedInfo 获取繁殖信息协议
|
||
// 前端到后端无数据 请求协议
|
||
func (ctl Controller) GetBreedInfo(
|
||
data *pet.C2S_GET_BREED_INFO, playerObj *player.Player) (result *pet.S2C_GET_BREED_INFO, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||
|
||
result = &pet.S2C_GET_BREED_INFO{}
|
||
// TODO: 实现获取繁殖信息的具体逻辑
|
||
return result, 0
|
||
|
||
}
|
||
|
||
// GetBreedPet 获取繁殖精灵
|
||
// 前端到后端
|
||
func (ctl Controller) GetBreedPet(
|
||
data *pet.C2S_GET_BREED_PET, playerObj *player.Player) (result *pet.S2C_GET_BREED_PET, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||
|
||
result = &pet.S2C_GET_BREED_PET{}
|
||
// TODO: 实现获取可繁殖雌性精灵列表的逻辑
|
||
// 这里只是示例,实际应该根据雄性精灵的catchTime查找可繁殖的雌性精灵
|
||
for _, v := range playerObj.Info.PetList {
|
||
// 如果是雌性精灵,且可以繁殖,则添加到列表
|
||
result.FemaleList = append(result.FemaleList, v.CatchTime)
|
||
}
|
||
return result, 0
|
||
|
||
}
|
||
|
||
// StartBreed 开始繁殖协议
|
||
// 前端到后端
|
||
func (ctl Controller) StartBreed(
|
||
data *pet.C2S_START_BREED, playerObj *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||
|
||
// TODO: 实现开始繁殖的具体逻辑
|
||
result = &fight.NullOutboundInfo{}
|
||
return result, 0
|
||
|
||
}
|
||
|
||
// GetEggList 获取精灵蛋数组
|
||
// 前端到后端无数据 请求协议
|
||
func (ctl Controller) GetEggList(
|
||
data *pet.C2S_GET_EGG_LIST, playerObj *player.Player) (result *pet.S2C_GET_EGG_LIST, err errorcode.ErrorCode) { //这个时候player应该是空的
|
||
|
||
result = &pet.S2C_GET_EGG_LIST{}
|
||
// TODO: 实现获取精灵蛋列表的逻辑
|
||
// 示例数据,实际应从玩家数据中获取
|
||
result.EggList = append(result.EggList, pet.EggInfo{EggID: 1, OwnerID: 10001, EggCatchTime: 122123})
|
||
return result, 0
|
||
|
||
}
|
||
|
||
// EffectHatch 精灵蛋互动协议
|
||
// 前端到后端
|
||
func (ctl Controller) EffectHatch(
|
||
data *pet.C2S_EFFECT_HATCH, playerObj *player.Player) (result *pet.S2C_EFFECT_HATCH, err errorcode.ErrorCode) {
|
||
|
||
result = &pet.S2C_EFFECT_HATCH{}
|
||
// TODO: 实现精灵蛋互动逻辑,根据互动ID更新亲密度
|
||
result.Intimacy = 1 // 悲伤
|
||
return result, 0
|
||
|
||
}
|
||
|
||
// StartHatch 开始孵化精灵蛋
|
||
// 前端到后端
|
||
func (ctl Controller) StartHatch(
|
||
data *pet.C2S_START_HATCH, playerObj *player.Player) (result *pet.S2C_START_HATCH, err errorcode.ErrorCode) {
|
||
|
||
// TODO: 实现开始孵化精灵蛋的具体逻辑
|
||
result = &pet.S2C_START_HATCH{}
|
||
return result, 0
|
||
|
||
}
|
||
|
||
// GetHatchPet 获得孵化精灵协议
|
||
// 前端到后端无数据内容 请求协议
|
||
func (ctl Controller) GetHatchPet(
|
||
data *pet.C2S_GET_HATCH_PET, playerObj *player.Player) (result *pet.S2C_GET_HATCH_PET, err errorcode.ErrorCode) {
|
||
|
||
result = &pet.S2C_GET_HATCH_PET{}
|
||
// TODO: 实现获得孵化精灵的具体逻辑,这里暂时返回默认值
|
||
result.PetID = 0
|
||
result.CatchTime = 0
|
||
return result, 0
|
||
|
||
} |