feat(space): 更新空间信息结构支持事件配置 - 替换天气字段为事件配置结构体 - 添加事件匹配逻辑验证天气和时间范围 - 实现事件驱动的BOSS显示控制机制 - 引入Event类型用于管理活动配置 ```
This commit is contained in:
@@ -2,6 +2,7 @@ package info
|
||||
|
||||
import (
|
||||
"blazing/common/data"
|
||||
configm "blazing/modules/config/model"
|
||||
"blazing/modules/player/model"
|
||||
|
||||
"github.com/creasty/defaults"
|
||||
@@ -44,7 +45,8 @@ type MapBossInfo struct {
|
||||
PosInfo []model.Pos `struc:"skip"`
|
||||
MaxHP int `struc:"skip"`
|
||||
PosIndex uint32 `struc:"skip"`
|
||||
Wer []int32 `struc:"skip"`
|
||||
//Wer []int32 `struc:"skip"`
|
||||
Event configm.Event `struc:"skip"`
|
||||
}
|
||||
|
||||
// 这里存储星球的map
|
||||
|
||||
@@ -208,7 +208,9 @@ func (ret *Space) init() {
|
||||
Hp: v.HP,
|
||||
PosInfo: ParseCoordinateString(v.Pos),
|
||||
MaxHP: int(v.HP),
|
||||
Wer: v.Weather,
|
||||
}
|
||||
if v.Event != nil {
|
||||
info.Event = *v.Event
|
||||
}
|
||||
|
||||
ret.MapBossSInfo.INFO = append(ret.MapBossSInfo.INFO, info)
|
||||
@@ -222,26 +224,41 @@ func (ret *Space) init() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
func (p *Space) IsMatch(t model.Event) bool {
|
||||
_, ok := lo.Find(t.Weather, func(item int32) bool {
|
||||
return item == int32(p.MapBossSInfo.Wer)
|
||||
})
|
||||
if !ok {
|
||||
// 不在同一天气下
|
||||
return false
|
||||
|
||||
}
|
||||
if t.StartTime != "" && t.EndTime != "" {
|
||||
ok, _ := utils.IsCurrentTimeInRange(t.StartTime, t.EndTime)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
}
|
||||
func (ret *Space) GenBoss() {
|
||||
|
||||
for i := 0; i < len(ret.MapBossSInfo.INFO); i++ {
|
||||
if !ret.IsMatch(ret.MapBossSInfo.INFO[i].Event) {
|
||||
ret.MapBossSInfo.INFO[i].IsShow = 0
|
||||
continue
|
||||
}
|
||||
s := len(ret.MapBossSInfo.INFO[i].PosInfo)
|
||||
if s != 0 {
|
||||
ret.MapBossSInfo.INFO[i].Pos = ret.MapBossSInfo.INFO[i].PosInfo[(grand.Intn(s-1)+1+int(ret.MapBossSInfo.INFO[i].PosIndex))%s]
|
||||
}
|
||||
|
||||
_, ok := lo.Find(ret.MapBossSInfo.INFO[i].Wer, func(item int32) bool {
|
||||
return item == ret.MapBossSInfo.Wer
|
||||
})
|
||||
if ok {
|
||||
ret.MapBossSInfo.INFO[i].IsShow = 1
|
||||
if ret.IsChange {
|
||||
ret.MapBossSInfo.INFO[i].IsShow = 2
|
||||
}
|
||||
} else {
|
||||
ret.MapBossSInfo.INFO[i].IsShow = 0
|
||||
|
||||
ret.MapBossSInfo.INFO[i].IsShow = 1
|
||||
if ret.IsChange {
|
||||
ret.MapBossSInfo.INFO[i].IsShow = 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user