refactor(maphot): 重构地图热度获取逻辑,将数据处理移至space服务
This commit is contained in:
@@ -11,16 +11,10 @@ func (h Controller) MapHot(data *maphot.InInfo, c *entity.Player) (result *mapho
|
||||
|
||||
result = &maphot.OutInfo{
|
||||
|
||||
HotInfos: make([]maphot.MapHotInfo, 0),
|
||||
HotInfos: space.GetMapHot(),
|
||||
}
|
||||
|
||||
for k, v := range space.GetMapHot() {
|
||||
result.HotInfos = append(result.HotInfos, maphot.MapHotInfo{
|
||||
MapID: uint32(k),
|
||||
Count: uint32(space.GetPlanet(uint32(v)).Len()),
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
package maphot
|
||||
|
||||
import "blazing/common/socket/handler"
|
||||
import (
|
||||
"blazing/common/socket/handler"
|
||||
"blazing/logic/service/space"
|
||||
)
|
||||
|
||||
// MapHotInfo 表示地图热度信息
|
||||
type MapHotInfo struct {
|
||||
MapID uint32 `json:"mapId"` // 地图ID
|
||||
Count uint32 `json:"count"` // 地图里的人数
|
||||
}
|
||||
type InInfo struct {
|
||||
Head handler.TomeeHeader `cmd:"1004" struc:"[0]pad"` //玩家登录
|
||||
}
|
||||
|
||||
func (m *InInfo) Def() []byte {
|
||||
|
||||
return m.Head.Pack(OutInfo{
|
||||
|
||||
HotInfos: make([]MapHotInfo, 0),
|
||||
}) //返回传参
|
||||
}
|
||||
|
||||
// OutInfo 表示地图热度的出站消息
|
||||
type OutInfo struct {
|
||||
HotInfosLen uint32 `json:"hotInfosLen" struc:"sizeof=HotInfos"` // 热度信息列表长度
|
||||
HotInfos []MapHotInfo `json:"hotInfos"` // 热度信息列表
|
||||
HotInfosLen uint32 `json:"hotInfosLen" struc:"sizeof=HotInfos"` // 热度信息列表长度
|
||||
HotInfos []space.MapHotInfo `json:"hotInfos"` // 热度信息列表
|
||||
}
|
||||
|
||||
@@ -8,7 +8,13 @@ import (
|
||||
"blazing/modules/blazing/model"
|
||||
)
|
||||
|
||||
func GetMapHot() map[uint32]uint32 {
|
||||
// MapHotInfo 表示地图热度信息
|
||||
type MapHotInfo struct {
|
||||
MapID uint32 `json:"mapId"` // 地图ID
|
||||
Count uint32 `json:"count"` // 地图里的人数
|
||||
}
|
||||
|
||||
func GetMapHot() []MapHotInfo {
|
||||
|
||||
tt := make(map[uint32]uint32)
|
||||
|
||||
@@ -23,7 +29,15 @@ func GetMapHot() map[uint32]uint32 {
|
||||
}
|
||||
|
||||
}
|
||||
return tt
|
||||
var result=make([]MapHotInfo,0)
|
||||
for k, v := range tt {
|
||||
result = append(result, MapHotInfo{
|
||||
MapID: uint32(k),
|
||||
Count: uint32(GetPlanet(uint32(v)).Len()),
|
||||
})
|
||||
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// 获取星球
|
||||
|
||||
Reference in New Issue
Block a user