From afe33770fd909272a9158ddf2f962c3be84fcf2a Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Tue, 11 Jul 2023 19:06:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=BB=E5=8A=A1=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 4 +- comm/imodule.go | 3 +- modules/buried/module.go | 13 ++-- modules/combat/module.go | 124 ---------------------------------- modules/passon/api_clearcd.go | 2 +- modules/passon/api_inroom.go | 2 +- modules/smithy/model_task.go | 3 +- modules/sociaty/module.go | 13 ++-- modules/wtask/module.go | 18 ++--- 9 files changed, 24 insertions(+), 158 deletions(-) diff --git a/comm/const.go b/comm/const.go index 03474fce5..578d810c6 100644 --- a/comm/const.go +++ b/comm/const.go @@ -365,8 +365,8 @@ const ( EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件 - EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32) - EventFriendChange core.Event_Key = "event_friend_change" //加好友 + //EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32) + EventFriendChange core.Event_Key = "event_friend_change" //加好友 ) const ( diff --git a/comm/imodule.go b/comm/imodule.go index d19ccd96b..d2aeca728 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -12,7 +12,7 @@ type ( } //埋点中心更新通知 IBuriedUpdateNotify interface { - BuriedsNotify(uid string, condis []*pb.ConIProgress) + BuriedsNotify(session IUserSession, condis []*pb.ConIProgress) } //任务完成 ITaskComplete interface { @@ -538,6 +538,7 @@ type ( } // 世界任务 IWtask interface { + IBuriedUpdateNotify IOpenCmdNotice } ) diff --git a/modules/buried/module.go b/modules/buried/module.go index d1270a75a..350cb95df 100644 --- a/modules/buried/module.go +++ b/modules/buried/module.go @@ -5,7 +5,6 @@ import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -549,15 +548,15 @@ func (this *Buried) trigger(session comm.IUserSession, burieds ...*pb.BuriedPara continue } //异步通知指定模块 - go nmodule.BuriedsNotify(session.GetUserId(), v) + nmodule.BuriedsNotify(session, v) } } - //通知事件 - if len(changes) > 0 { - this.Debug("条件变化通知", log.Field{Key: "ConIds", Value: changes}) - event.TriggerEvent(comm.EventBuriedComplete, session.GetUserId(), changes) - } + // //通知事件 + // if len(changes) > 0 { + // this.Debug("条件变化通知", log.Field{Key: "ConIds", Value: changes}) + // event.TriggerEvent(comm.EventBuriedComplete, session.GetUserId(), changes) + // } } // 更新并校验完成 diff --git a/modules/combat/module.go b/modules/combat/module.go index 8a0f7e4fe..536395872 100644 --- a/modules/combat/module.go +++ b/modules/combat/module.go @@ -7,9 +7,6 @@ import ( "go_dreamfactory/lego/sys/event" "go_dreamfactory/modules" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" - - "go_dreamfactory/lego/sys/log" ) /* @@ -76,124 +73,3 @@ func (this *Combat) GetLevels(uid string) (levels map[int32]*pb.DBCombatLevel) { levels = combat.Level return } - -//任务埋点通知 -func (this *Combat) BuriedsNotify(uid string, condis []*pb.ConIProgress) { - this.Debug("收到埋点中心 进度改变通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condis", Value: condis}) - //废弃 采用主动询问机制 - return - - var ( - err error - session comm.IUserSession - online bool - info *pb.DBCombatUser - lvconf *cfg.GameCombatLevelData - progress []*pb.LevelProgressItem - pitem *pb.LevelProgressItem - ok bool - pass bool - ) - session, online = this.GetUserSession(uid) - defer func() { - if online { - session.Push() - } - this.PutUserSession(session) - }() - if info, err = this.modelCombat.queryInfo(uid); err != nil { - return - } - progress = make([]*pb.LevelProgressItem, 0) - for _, l := range info.Level { - l.Progress = 0 - pitem = &pb.LevelProgressItem{ - Level: l.Id, - Passmaintask: l.Passmaintask, - Passpertask: l.Passpertask, - Progress: l.Progress, - Pass: l.Pass, - Mainaward: make([]*pb.UserAssets, 0), - Peraward: make([]*pb.UserAssets, 0), - } - if l.Pass != 2 { - ok = false - pass = true - for _, v := range l.Passmaintask { - for _, v1 := range condis { - if v.Conid == v1.Conid { - ok = true - v.Value = v1.Value - v.State = v1.State - } - } - l.Progress += v.Value - if v.State != 1 { - pass = false - } - } - - if l.Pass == 0 && pass { //基础通关达成 - l.Pass = 1 - pitem.Pass = l.Pass - if lvconf, err = this.configure.getCombatLevel(l.Id); err != nil { - this.Error("BuriedsNotify 执行错误!", log.Field{Key: "err", Value: err.Error()}) - return - } - this.DispenseRes(session, lvconf.Award, true) - atns := make([]*pb.UserAssets, len(lvconf.Award)) - for i, v := range lvconf.Award { - atns[i] = &pb.UserAssets{ - A: v.A, - T: v.T, - N: v.N, - } - } - pitem.Mainaward = atns - - } - pass = true - for _, v := range l.Passpertask { - for _, v1 := range condis { - if v.Conid == v1.Conid { - ok = true - v.Value = v1.Value - v.State = v1.State - } - } - l.Progress += v.Value - if v.State != 1 { - pass = false - } - } - - if l.Pass == 1 && pass { //完美通关完成 - l.Pass = 2 - pitem.Pass = l.Pass - if lvconf, err = this.configure.getCombatLevel(l.Id); err != nil { - this.Error("BuriedsNotify 执行错误!", log.Field{Key: "err", Value: err.Error()}) - return - } - this.DispenseRes(session, lvconf.Profectaward, true) - atns := make([]*pb.UserAssets, len(lvconf.Profectaward)) - for i, v := range lvconf.Profectaward { - atns[i] = &pb.UserAssets{ - A: v.A, - T: v.T, - N: v.N, - } - } - pitem.Peraward = atns - } - pitem.Progress = l.Progress - if ok { - progress = append(progress, pitem) - } - } - } - - if len(progress) > 0 { - session.SendMsg(string(this.GetType()), "progress", &pb.CombatProgressPush{Levels: progress}) - } - -} diff --git a/modules/passon/api_clearcd.go b/modules/passon/api_clearcd.go index bc2caaa6a..b0c5bbc77 100644 --- a/modules/passon/api_clearcd.go +++ b/modules/passon/api_clearcd.go @@ -24,7 +24,7 @@ func (this *apiComp) ClearCD(session comm.IUserSession, req *pb.PassonClearCDReq if errdata = this.ClearCDCheck(session, req); errdata != nil { return } - if conf, err = this.module.configure.GetPassonConf(req.Index); err != nil { + if conf, err = this.module.configure.GetPassonConf(req.Index + 1); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), diff --git a/modules/passon/api_inroom.go b/modules/passon/api_inroom.go index 704d4ba30..fb3e85053 100644 --- a/modules/passon/api_inroom.go +++ b/modules/passon/api_inroom.go @@ -87,7 +87,7 @@ func (this *apiComp) InRoom(session comm.IUserSession, req *pb.PassonInRoomReq) } if passon.Student[req.Index].State != 2 { - if conf, err = this.module.configure.GetPassonConf(req.Index); err != nil { + if conf, err = this.module.configure.GetPassonConf(req.Index + 1); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ConfigNoFound, Title: pb.ErrorCode_ConfigNoFound.ToString(), diff --git a/modules/smithy/model_task.go b/modules/smithy/model_task.go index adf672a50..6eb57ca98 100644 --- a/modules/smithy/model_task.go +++ b/modules/smithy/model_task.go @@ -3,7 +3,6 @@ package smithy import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -24,7 +23,7 @@ func (this *modelTask) Init(service core.IService, module core.IModule, comp cor this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, }) - event.Register(comm.EventBuriedComplete, this.TCondFinishNotify) + // event.Register(comm.EventBuriedComplete, this.TCondFinishNotify) return } diff --git a/modules/sociaty/module.go b/modules/sociaty/module.go index 8835d65e6..2de2e0033 100644 --- a/modules/sociaty/module.go +++ b/modules/sociaty/module.go @@ -10,7 +10,6 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -61,7 +60,7 @@ func (this *Sociaty) OnInstallComp() { this.modelSociatyLog = this.RegisterComp(new(ModelSociatyLog)).(*ModelSociatyLog) this.modelSociatyBoss = this.RegisterComp(new(ModelSociatyBoss)).(*ModelSociatyBoss) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) - event.Register(comm.EventBuriedComplete, this.TCondFinishNotify) + // event.Register(comm.EventBuriedComplete, this.TCondFinishNotify) } func (this *Sociaty) Start() (err error) { @@ -275,12 +274,12 @@ type TaskParams struct { } // 任务条件达成通知 -func (this *Sociaty) TCondFinishNotify(uid string, conds []*pb.ConIProgress) { +func (this *Sociaty) TCondFinishNotify(session comm.IUserSession, conds []*pb.ConIProgress) { log.Debug("公会任务通知", - log.Field{Key: "uid", Value: uid}, + log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condIds", Value: conds}) - sociaty := this.modelSociaty.getUserSociaty(uid) + sociaty := this.modelSociaty.getUserSociaty(session.GetUserId()) if sociaty == nil { return } @@ -290,7 +289,7 @@ func (this *Sociaty) TCondFinishNotify(uid string, conds []*pb.ConIProgress) { dt := &pb.DBSociatyTask{} err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), comm.Service_Worker, string(comm.Rpc_ModuleSociatyGetTask), - &pb.RPCGeneralReqA2{Param1: sociatyId, Param2: uid}, dt) + &pb.RPCGeneralReqA2{Param1: sociatyId, Param2: session.GetUserId()}, dt) var flag bool for _, v := range dt.TaskList { @@ -312,7 +311,7 @@ func (this *Sociaty) TCondFinishNotify(uid string, conds []*pb.ConIProgress) { err = this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), comm.Service_Worker, string(comm.Rpc_ModuleSociatyTask), - &TaskParams{SociatyId: sociatyId, Uid: uid, Data: update}, &pb.EmptyResp{}) + &TaskParams{SociatyId: sociatyId, Uid: session.GetUserId(), Data: update}, &pb.EmptyResp{}) if err != nil { return } diff --git a/modules/wtask/module.go b/modules/wtask/module.go index 71774cda7..bd8234bc0 100644 --- a/modules/wtask/module.go +++ b/modules/wtask/module.go @@ -4,7 +4,6 @@ import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -48,7 +47,7 @@ func (this *WTask) Start() (err error) { return } this.modelSys = module.(comm.ISys) - event.Register(comm.EventBuriedComplete, this.BuriedsNotify) + // event.Register(comm.EventBuriedComplete, this.BuriedsNotify) return } @@ -61,9 +60,8 @@ func (this *WTask) OnInstallComp() { } // 埋点通知 -func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) { +func (this *WTask) BuriedsNotify(session comm.IUserSession, condis []*pb.ConIProgress) { var ( - session comm.IUserSession condisMap map[int32]*pb.ConIProgress = make(map[int32]*pb.ConIProgress) utask *pb.DBWTask accepttaskMap map[int32]struct{} = make(map[int32]struct{}) @@ -78,8 +76,8 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) { err error ) - this.Debug("收到子任务进度变化推送", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condis", Value: condis}) - if utask, err = this.modelwtask.getUserWTasks(uid); err != nil { + this.Debug("收到子任务进度变化推送", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "condis", Value: condis}) + if utask, err = this.modelwtask.getUserWTasks(session.GetUserId()); err != nil { this.Error("读取玩家世界任务数据 失败", log.Field{Key: "err", Value: err.Error()}) return } @@ -119,7 +117,7 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) { } } if needcheck { //校验有变化的任务 的完成条件 - if condis, err = this.ModuleBuried.CheckCondition(uid, checkcondls...); err != nil { + if condis, err = this.ModuleBuried.CheckCondition(session.GetUserId(), checkcondls...); err != nil { this.Error("校验玩家子任务进度数据 失败", log.Field{Key: "err", Value: err.Error()}) return } @@ -139,12 +137,6 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) { } detailstasks = append(detailstasks, task) } - - session, _ = this.GetUserSession(uid) - defer func() { - session.Push() - this.PutUserSession(session) - }() //发送进度变化消息 session.SendMsg(string(this.GetType()), "acceptchange", &pb.WTaskAcceptChangePush{Accepts: detailstasks}) }