From 67f57d95ea047f639012daab4b05b5a176496e88 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 21 Nov 2022 11:20:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=9F=E5=BA=A7=E5=9B=BE=E7=BA=A2=E7=82=B9?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/horoscope/configure.go | 19 ++++++++++++++++++- modules/horoscope/modelhoroscope.go | 26 ++++++++++++++++++++++++++ modules/horoscope/module.go | 5 ++++- modules/reddot/api_get.go | 7 ++++--- modules/reddot/api_getall.go | 3 +++ modules/reddot/module.go | 5 +++++ 6 files changed, 60 insertions(+), 5 deletions(-) diff --git a/modules/horoscope/configure.go b/modules/horoscope/configure.go index e9e4eaa23..07d24e141 100644 --- a/modules/horoscope/configure.go +++ b/modules/horoscope/configure.go @@ -69,7 +69,7 @@ func (this *configureComp) getHeroConfig(id string) (result *cfg.GameHeroData, e v interface{} ok bool ) - if v, err = this.GetConfigure(game_horoscope); err != nil { + if v, err = this.GetConfigure(game_hero); err != nil { this.module.Errorln(err) } else { if result, ok = v.(*cfg.GameHero).GetDataMap()[id]; !ok { @@ -79,3 +79,20 @@ func (this *configureComp) getHeroConfig(id string) (result *cfg.GameHeroData, e } return } + +//查询下一个节点 +func (this *configureComp) getHoroscopes() (result *cfg.GameHoroscope, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_horoscope); err != nil { + this.module.Errorln(err) + } else { + if result, ok = v.(*cfg.GameHoroscope); !ok { + err = fmt.Errorf("on found game_horoscope 类型异常") + this.module.Errorln(err) + } + } + return +} diff --git a/modules/horoscope/modelhoroscope.go b/modules/horoscope/modelhoroscope.go index 6662532da..ce6875567 100644 --- a/modules/horoscope/modelhoroscope.go +++ b/modules/horoscope/modelhoroscope.go @@ -139,3 +139,29 @@ func (this *modelHoroscope) compute(info *pb.DBHoroscope, hero *pb.DBHero) (err } return } + +func (this *modelHoroscope) reddot(session comm.IUserSession) bool { + var ( + info *pb.DBHoroscope + horoscope *cfg.GameHoroscope + code pb.ErrorCode + err error + ) + if info, err = this.queryInfo(session.GetUserId()); err != nil { + return false + } + if horoscope, err = this.module.configure.getHoroscopes(); err != nil { + return false + } + + for _, v := range horoscope.GetDataList() { + + if lv, ok := info.Nodes[v.NodeId]; !ok && v.Lv > lv { + + if code = this.module.CheckRes(session, v.CostItem); code == pb.ErrorCode_Success { + return true + } + } + } + return false +} diff --git a/modules/horoscope/module.go b/modules/horoscope/module.go index deccbd596..71506aa44 100644 --- a/modules/horoscope/module.go +++ b/modules/horoscope/module.go @@ -59,11 +59,14 @@ func (this *Horoscope) ComputeHeroNumeric(uid string, hero ...*pb.DBHero) { } //红点需求 -func (this *Horoscope) Reddot(uid string, rid ...comm.ReddotType) (result map[comm.ReddotType]bool) { +func (this *Horoscope) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (result map[comm.ReddotType]bool) { result = make(map[comm.ReddotType]bool) for _, v := range rid { switch v { case comm.Reddot17: + if isredot := this.modelHoroscope.reddot(session); isredot { + result[comm.Reddot17] = true + } break } } diff --git a/modules/reddot/api_get.go b/modules/reddot/api_get.go index dca87e97c..a603c3c33 100644 --- a/modules/reddot/api_get.go +++ b/modules/reddot/api_get.go @@ -40,12 +40,13 @@ func (this *apiComp) Get(session comm.IUserSession, req *pb.ReddotGetReq) (code for k, v := range this.module.ModuleTask.Reddot(session, comm.Reddot2) { reddot[int32(k)] = v } + case int32(comm.Reddot17): + for k, v := range this.module.horoscope.Reddot(session, comm.Reddot2) { + reddot[int32(k)] = v + } } } - // for k, v := range this.module.martialhall.Reddot(session.GetUserId(), comm.Reddot1) { - // reddot[int32(k)] = v - // } session.SendMsg(string(this.module.GetType()), "get", &pb.ReddotGetAllResp{Reddot: reddot}) return } diff --git a/modules/reddot/api_getall.go b/modules/reddot/api_getall.go index 28b81215a..2bfa3e9b8 100644 --- a/modules/reddot/api_getall.go +++ b/modules/reddot/api_getall.go @@ -30,6 +30,9 @@ func (this *apiComp) GetAll(session comm.IUserSession, req *pb.ReddotGetAllReq) for k, v := range this.module.pagoda.Reddot(session, comm.Reddot6) { reddot[int32(k)] = v } + for k, v := range this.module.horoscope.Reddot(session, comm.Reddot17) { + reddot[int32(k)] = v + } session.SendMsg(string(this.module.GetType()), "getall", &pb.ReddotGetAllResp{Reddot: reddot}) return } diff --git a/modules/reddot/module.go b/modules/reddot/module.go index 9d5334943..64da2c262 100644 --- a/modules/reddot/module.go +++ b/modules/reddot/module.go @@ -23,6 +23,7 @@ type Reddot struct { mainline comm.IMainline pagoda comm.IPagoda martialhall comm.IMartialhall + horoscope comm.IHoroscope api_comp *apiComp } @@ -52,6 +53,10 @@ func (this *Reddot) Start() (err error) { return } this.martialhall = module.(comm.IMartialhall) + if module, err = this.service.GetModule(comm.ModuleHoroscope); err != nil { + return + } + this.horoscope = module.(comm.IHoroscope) return }