feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
85 lines
3.0 KiB
Go
85 lines
3.0 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/modules/player/model"
|
|
|
|
"blazing/logic/service/pet"
|
|
"blazing/logic/service/player"
|
|
"blazing/logic/service/room"
|
|
|
|
"github.com/jinzhu/copier"
|
|
)
|
|
|
|
// GetFitmentUsing 获取基地展示的家具物品
|
|
// data: 包含目标用户ID的输入信息
|
|
// c: 当前玩家对象
|
|
// 返回: 基地家具信息和错误码
|
|
func (h Controller) GetFitmentUsing(data *room.FitmentUseringInboundInfo, c *player.Player) (result *room.FitmentUseringOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &room.FitmentUseringOutboundInfo{UserId: c.Info.UserID, RoomId: data.TargetUserID}
|
|
result.Fitments = make([]model.FitmentShowInfo, 0)
|
|
result.Fitments = append(result.Fitments, model.FitmentShowInfo{Id: 500001, Status: 1, X: 1, Y: 1, Dir: 1})
|
|
|
|
roomInfo := c.Service.Room.Get(data.TargetUserID)
|
|
result.Fitments = append(result.Fitments, roomInfo.PlacedItems...)
|
|
return
|
|
}
|
|
|
|
// GetRoomPetShowInfo 获取基地展示的精灵列表
|
|
// data: 包含目标用户ID的输入信息
|
|
// c: 当前玩家对象
|
|
// 返回: 精灵展示列表和错误码
|
|
func (h Controller) GetRoomPetShowInfo(data *room.PetRoomListInboundInfo, c *player.Player) (result *room.PetRoomListOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &room.PetRoomListOutboundInfo{}
|
|
result.Pets = make([]pet.PetShortInfo, 0)
|
|
roomInfo := c.Service.Room.Get(data.TargetUserID)
|
|
for _, catchTime := range roomInfo.ShowPokemon {
|
|
petInfo := c.Service.Pet.PetInfo_One_ohter(data.TargetUserID, catchTime)
|
|
if petInfo.Data.ID == 0 {
|
|
continue
|
|
}
|
|
var petShortInfo pet.PetShortInfo
|
|
copier.Copy(&petShortInfo, &petInfo.Data)
|
|
if petInfo.ID != 0 {
|
|
result.Pets = append(result.Pets, petShortInfo)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// GetAllFurniture 获取玩家的所有家具
|
|
// data: 空输入结构
|
|
// c: 当前玩家对象
|
|
// 返回: 玩家所有家具列表和错误码
|
|
func (h Controller) GetAllFurniture(data *room.FitmentAllInboundEmpty, c *player.Player) (result *room.FitmentAllOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &room.FitmentAllOutboundInfo{}
|
|
result.Fitments = make([]room.FitmentItemInfo, 0)
|
|
|
|
items := c.Service.Item.Get(500000, 600000)
|
|
roomData := c.Service.Room.Get(c.Info.UserID)
|
|
for _, item := range items {
|
|
var itemInfo room.FitmentItemInfo
|
|
itemInfo.Id = item.ItemId
|
|
itemInfo.AllCount = item.ItemCnt
|
|
i, ok := roomData.UsedItems[item.ItemId]
|
|
if ok {
|
|
itemInfo.UsedCount = i
|
|
}
|
|
result.Fitments = append(result.Fitments, itemInfo)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetRoomPetInfo 获取玩家跟随精灵的信息
|
|
// data: 包含用户ID和精灵捕获时间的输入信息
|
|
// c: 当前玩家对象
|
|
// 返回: 精灵详细信息和错误码
|
|
func (h Controller) GetRoomPetInfo(data *room.C2S_RoomPetInfo, c *player.Player) (result *pet.RoomPetInfo, err errorcode.ErrorCode) {
|
|
petInfo := c.Service.Pet.PetInfo_One_ohter(data.UserID, data.CatchTime)
|
|
result = &pet.RoomPetInfo{}
|
|
copier.CopyWithOption(result, &petInfo.Data, copier.Option{DeepCopy: true})
|
|
result.OwnerId = data.UserID
|
|
return
|
|
}
|