refactor: 优化地图节点数据获取逻辑
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

将获取地图Boss信息的过滤逻辑从循环中移至GetDataB方法
This commit is contained in:
xinian
2026-02-27 11:06:03 +08:00
committed by cnb
parent bc2f222036
commit ad43fc8173
2 changed files with 19 additions and 13 deletions

View File

@@ -104,21 +104,19 @@ func GetSpace(id uint32) *Space {
// ret.CanWeather = 1
cool.Cron.CustomFunc(ret, ret.GenWer)
}
for _, v := range service.NewMapNodeService().GetData(ret.ID) {
if v.IsBroadcast != 0 { //说明是地图怪
info := info.MapBossInfo{
Id: v.TriggerID,
Region: v.NodeID, //这个是注册的index
Hp: v.HP,
PosInfo: ParseCoordinateString(v.Pos),
MaxHP: int(v.HP),
Wer: v.Weather,
}
ret.MapBossSInfo.INFO = append(ret.MapBossSInfo.INFO, info)
for _, v := range service.NewMapNodeService().GetDataB(ret.ID) {
info := info.MapBossInfo{
Id: v.TriggerID,
Region: v.NodeID, //这个是注册的index
Hp: v.HP,
PosInfo: ParseCoordinateString(v.Pos),
MaxHP: int(v.HP),
Wer: v.Weather,
}
ret.MapBossSInfo.INFO = append(ret.MapBossSInfo.INFO, info)
}
if len(ret.MapBossSInfo.INFO) > 0 {

View File

@@ -27,6 +27,14 @@ func (s *MapNodeService) GetData(mapid uint32) []model.MapNode {
return pet
}
func (s *MapNodeService) GetDataB(mapid uint32) []model.MapNode {
var pet []model.MapNode //一个特性应该是唯一的,但是我们要获取默认随机特性
dbm_enable(s.Model).Where("map_id", mapid).Where("is_broadcast", 1).Scan(&pet)
return pet
}
func (s *MapNodeService) GetDataNode(mapid, node uint32) *model.MapNode {