All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
将地图热度信息从简单的计数器改为包含提示信息的结构体 添加矿物、BOSS、宠物和掉落等提示信息的收集功能 优化地图进入和离开时的计数逻辑
75 lines
1.5 KiB
Go
75 lines
1.5 KiB
Go
package space
|
|
|
|
// MapHotInfo 表示地图热度信息
|
|
type MapHotInfo struct {
|
|
MapID uint32 `json:"mapId"` // 地图ID
|
|
Count int32 `struc:"uint32" json:"count"` // 地图里的人数
|
|
}
|
|
type MapTip struct {
|
|
Count int `struc:"uint32" json:"count"` // 地图里的人数
|
|
TipInfoS map[uint32]*TipInfo `json:"tipInfoS"`
|
|
}
|
|
|
|
type TipInfo struct {
|
|
Talk []uint32 `json:"talk"` //矿物
|
|
Boss []uint32 `json:"boss"` //boss
|
|
Pet []uint32 `json:"pet"` //宠物
|
|
Diao []uint32 `json:"diao"` //掉落
|
|
}
|
|
|
|
func (m *MapTip) GetCount(t int) int {
|
|
|
|
switch {
|
|
case t < 0:
|
|
if m.Count > 0 {
|
|
m.Count -= t
|
|
}
|
|
case t > 0:
|
|
m.Count += t
|
|
}
|
|
|
|
return m.Count
|
|
}
|
|
|
|
var maphot = make(map[uint32]*MapTip, 0)
|
|
|
|
func GetMapHot() []MapHotInfo {
|
|
ret := make([]MapHotInfo, 0)
|
|
for k, v := range maphot {
|
|
ret = append(ret, MapHotInfo{
|
|
MapID: k,
|
|
Count: int32(v.GetCount(0)),
|
|
})
|
|
|
|
}
|
|
|
|
return ret
|
|
// result1, _, _ := requestGroup.Do("map_hot", func() (interface{}, error) {
|
|
|
|
// tt := make(map[uint32]uint32)
|
|
|
|
// for _, v := range xmlres.MapConfig.Maps {
|
|
|
|
// t1, ok := tt[uint32(v.Super)]
|
|
// if ok {
|
|
// tt[uint32(v.Super)] = uint32(int(t1) + GetSpace(uint32(v.ID)).User.Count())
|
|
|
|
// } else {
|
|
// tt[uint32(v.Super)] = uint32(GetSpace(uint32(v.ID)).User.Count())
|
|
// }
|
|
|
|
// }
|
|
// var result = make([]MapHotInfo, 0)
|
|
// for k, v := range tt {
|
|
|
|
// result = append(result, MapHotInfo{
|
|
// MapID: uint32(k),
|
|
// Count: uint32(v),
|
|
// })
|
|
|
|
// }
|
|
// return result, nil
|
|
// })
|
|
|
|
}
|