diff --git a/logic/service/space/info/info.go b/logic/service/space/info/info.go index 33046fe65..ee41e7c7c 100644 --- a/logic/service/space/info/info.go +++ b/logic/service/space/info/info.go @@ -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 diff --git a/logic/service/space/space.go b/logic/service/space/space.go index fbef190e4..0771c2865 100644 --- a/logic/service/space/space.go +++ b/logic/service/space/space.go @@ -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 } }