From 0405e8682f5840d535baf392e7fd74df1876df67 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 18 Sep 2023 17:55:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=AE=A1=E5=8D=A1=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E6=8E=89=E8=90=BD=E7=BB=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/combat/api_drop.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/combat/api_drop.go b/modules/combat/api_drop.go index a0f6e3bd4..c3aabf602 100644 --- a/modules/combat/api_drop.go +++ b/modules/combat/api_drop.go @@ -1,6 +1,7 @@ package combat import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -70,7 +71,25 @@ func (this *apiComp) Drop(session comm.IUserSession, req *pb.CombatDropReq) (err } return } - reward := this.module.configure.GetDropReward(box.Drop) + user, err := this.module.ModuleUser.GetUser(session.GetUserId()) + if err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + reward := this.module.ModuleTools.GetGroupDataByLottery(box.Drop, user.Vip, user.Lv) + if len(reward) == 0 { + //if prop = this.module.configure.GetDropData(itemcf.BoxId); prop == nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: fmt.Sprintf("Lottery no found!:%d", box.Drop), + } + return + } this.module.DispenseRes(session, reward, true) atns = make([]*pb.UserAssets, len(reward)) for i, v := range reward { From 221ed62dac6ed79fc94e21c6dd1e94da6c75aafe Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 18 Sep 2023 18:24:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=97=A5=E5=B8=B8?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 3 +- modules/dailytask/module.go | 104 +++++++++++++++++++------------- modules/practice/module.go | 8 +-- modules/sys/api_funcactivate.go | 25 ++++---- modules/sys/api_funcgetList.go | 10 ++- modules/turntable/module.go | 2 +- modules/wtask/module.go | 20 ++---- 7 files changed, 95 insertions(+), 77 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 5820e358e..11cf85e31 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -20,7 +20,7 @@ type ( } //功能开启通知 IOpenCmdNotice interface { - OpenCmdNotice(uid string, keys ...string) + OpenCmdNotice(session IUserSession, keys ...string) } // 活动通知 IActivityNotice interface { @@ -583,6 +583,7 @@ type ( } //每日任务 IDailytask interface { + IOpenCmdNotice IGetReddot //任务组完成 TaskGroupComplete(session IUserSession, group int32) diff --git a/modules/dailytask/module.go b/modules/dailytask/module.go index 8abe429f2..a46fa8df9 100644 --- a/modules/dailytask/module.go +++ b/modules/dailytask/module.go @@ -46,7 +46,7 @@ func (this *Dailytask) Start() (err error) { return } this.wtask = module.(comm.IWtask) - event.RegisterGO(comm.EventUserLogin, this.EventUserLogin) + event.Register(comm.EventUserLogin, this.EventUserLogin) return } @@ -61,56 +61,19 @@ func (this *Dailytask) OnInstallComp() { // 用户登录 func (this *Dailytask) EventUserLogin(session comm.IUserSession) { var ( - dtask *pb.DBDailytask - user *pb.DBUser errdata *pb.ErrorData - key int32 - group []int32 - tasks map[int32][]int32 - err error + isopen bool ) if db.IsCross() { //跨服不支持 return } - if dtask, err = this.modelDailytask.getUserDTasks(session.GetUserId()); err != nil { - this.Errorln(err) + if isopen, errdata = this.ModuleSys.CheckOpenCondCfgById(session.GetUserId(), "annulartask"); isopen { + this.Errorln(errdata) return } - - if !utils.IsToday(dtask.Rtime) { //不是同一天 重置 - if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil { - this.Error("no found user", log.Field{Key: "uid", Value: session.GetUserId()}) - return - } - if key, group, err = this.modelDailytask.resetUserDTasks(user.Lv); err != nil { - this.Errorln(err) - return - } - if tasks, errdata = this.wtask.ResetDailytaskTask(session.Clone(), key, group...); errdata != nil { - this.Errorln(errdata) - return - } - dtask.Key = key - dtask.Groups = make([]*pb.DBDailytaskGroup, 0) - for k, v := range tasks { - dtask.Groups = append(dtask.Groups, &pb.DBDailytaskGroup{ - Group: k, - Tasks: v, - }) - } - dtask.Rtime = configure.Now().Unix() - if err = this.modelDailytask.Change(session.GetUserId(), map[string]interface{}{ - "key": dtask.Key, - "groups": dtask.Groups, - "rtime": dtask.Rtime, - }); err != nil { - this.Errorln(err) - return - } - } - + this.refreshtask(session) } // 任务组完成 @@ -137,6 +100,15 @@ func (this *Dailytask) TaskGroupComplete(session comm.IUserSession, group int32) } } +// 功能是否开启 +func (this *Dailytask) OpenCmdNotice(session comm.IUserSession, keys ...string) { + for _, v := range keys { + if v == "annulartask" { //日常功能开启 + this.refreshtask(session) + } + } +} + // 查询每日红点信息 func (this *Dailytask) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { var ( @@ -168,3 +140,51 @@ func (this *Dailytask) Reddot(session comm.IUserSession, rid ...comm.ReddotType) } return } + +func (this *Dailytask) refreshtask(session comm.IUserSession) { + var ( + dtask *pb.DBDailytask + user *pb.DBUser + errdata *pb.ErrorData + key int32 + group []int32 + tasks map[int32][]int32 + err error + ) + if dtask, err = this.modelDailytask.getUserDTasks(session.GetUserId()); err != nil { + this.Errorln(err) + return + } + + if !utils.IsToday(dtask.Rtime) { //不是同一天 重置 + if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil { + this.Error("no found user", log.Field{Key: "uid", Value: session.GetUserId()}) + return + } + if key, group, err = this.modelDailytask.resetUserDTasks(user.Lv); err != nil { + this.Errorln(err) + return + } + if tasks, errdata = this.wtask.ResetDailytaskTask(session, key, group...); errdata != nil { + this.Errorln(errdata) + return + } + dtask.Key = key + dtask.Groups = make([]*pb.DBDailytaskGroup, 0) + for k, v := range tasks { + dtask.Groups = append(dtask.Groups, &pb.DBDailytaskGroup{ + Group: k, + Tasks: v, + }) + } + dtask.Rtime = configure.Now().Unix() + if err = this.modelDailytask.Change(session.GetUserId(), map[string]interface{}{ + "key": dtask.Key, + "groups": dtask.Groups, + "rtime": dtask.Rtime, + }); err != nil { + this.Errorln(err) + return + } + } +} diff --git a/modules/practice/module.go b/modules/practice/module.go index 9ff4e1430..996384827 100644 --- a/modules/practice/module.go +++ b/modules/practice/module.go @@ -210,9 +210,9 @@ func (this *Practice) TaskComplete(session comm.IUserSession, taskid ...int32) { ) } -func (this *Practice) OpenCmdNotice(uid string, keys ...string) { +func (this *Practice) OpenCmdNotice(session comm.IUserSession, keys ...string) { this.Debug("OpenCmdNotice", - log.Field{Key: "session", Value: uid}, + log.Field{Key: "session", Value: session.GetUserId()}, log.Field{Key: "key", Value: keys}, ) if !this.IsCross() { @@ -220,7 +220,7 @@ func (this *Practice) OpenCmdNotice(uid string, keys ...string) { if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" { err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), comm.Service_Worker, string(comm.RPC_ModulePracticeUnLockPillar), - &pb.RPCGeneralReqA2{Param1: uid, Param2: v}, &pb.EmptyResp{}) + &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{}) if err != nil { this.Errorln(err) return @@ -231,7 +231,7 @@ func (this *Practice) OpenCmdNotice(uid string, keys ...string) { } else { for _, v := range keys { if v == "practice_ pillar1" || v == "practice_ pillar2" || v == "practice_ pillar3" { - this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: uid, Param2: v}, &pb.EmptyResp{}) + this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{}) } } } diff --git a/modules/sys/api_funcactivate.go b/modules/sys/api_funcactivate.go index db1f7b28d..7fe82dff8 100644 --- a/modules/sys/api_funcactivate.go +++ b/modules/sys/api_funcactivate.go @@ -65,18 +65,21 @@ func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActi return } - go this.module.wtask.OpenCmdNotice(session.GetUserId(), req.Cid) - //手动激活通知模块 - for _, m := range opencfg.Notify { - i, err := this.service.GetModule(core.M_Modules(m)) - if err != nil { - this.module.Errorln(err) - continue - } + go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { + this.module.wtask.OpenCmdNotice(session, req.Cid) + //手动激活通知模块 + for _, m := range opencfg.Notify { + i, err := this.service.GetModule(core.M_Modules(m)) + if err != nil { + this.module.Errorln(err) + continue + } - if ic, ok := i.(comm.IOpenCmdNotice); ok { - go ic.OpenCmdNotice(session.GetUserId(), req.Cid) + if ic, ok := i.(comm.IOpenCmdNotice); ok { + ic.OpenCmdNotice(session, req.Cid) + } } - } + }) + return } diff --git a/modules/sys/api_funcgetList.go b/modules/sys/api_funcgetList.go index 5d1c254e6..7a16fb903 100644 --- a/modules/sys/api_funcgetList.go +++ b/modules/sys/api_funcgetList.go @@ -76,9 +76,13 @@ func (this *apiComp) FuncGetList(session comm.IUserSession, req *pb.SysFuncGetLi "cond": list.Cond, }) } - if len(change) > 0 { - go this.module.wtask.OpenCmdNotice(session.GetUserId(), change...) - } session.SendMsg(string(this.module.GetType()), "funcgetlist", rsp) + + if len(change) > 0 { + go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { + this.module.wtask.OpenCmdNotice(session, change...) + }) + + } return } diff --git a/modules/turntable/module.go b/modules/turntable/module.go index 6d6422b03..48161b8ae 100644 --- a/modules/turntable/module.go +++ b/modules/turntable/module.go @@ -48,7 +48,7 @@ func (this *Turntable) Start() (err error) { if module, err = this.service.GetModule(comm.ModuleWarorder); err != nil { return } - event.RegisterGO(comm.EventUserLogin, this.EventUserLogin) + event.Register(comm.EventUserLogin, this.EventUserLogin) return } diff --git a/modules/wtask/module.go b/modules/wtask/module.go index ad4d2e4a6..6389489f9 100644 --- a/modules/wtask/module.go +++ b/modules/wtask/module.go @@ -154,7 +154,7 @@ func (this *WTask) BuriedsNotify(session comm.IUserSession, condis []*pb.ConIPro } // 功能开启 -func (this *WTask) OpenCmdNotice(uid string, keys ...string) { +func (this *WTask) OpenCmdNotice(session comm.IUserSession, keys ...string) { var ( opencmdTask map[string][]*cfg.GameWorldTaskData user *pb.DBUser @@ -169,21 +169,16 @@ func (this *WTask) OpenCmdNotice(uid string, keys ...string) { break } } - if user, err = this.ModuleUser.GetUser(uid); err != nil { - this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: uid}) + if user, err = this.ModuleUser.GetUser(session.GetUserId()); err != nil { + this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: session.GetUserId()}) return } - if wtask, err = this.modelwtask.getUserWTasks(uid); err != nil { - this.Error("获取世界任务数据 失败!", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) + if wtask, err = this.modelwtask.getUserWTasks(session.GetUserId()); err != nil { + this.Error("获取世界任务数据 失败!", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "err", Value: err.Error()}) return } - session, _ := this.GetUserSession(uid) - defer func() { - session.Push() - this.PutUserSession(session) - }() this.inquireActivations(session, wtask, user.Lv, keys, true) } @@ -277,11 +272,6 @@ func (this *WTask) ResetDailytaskTask(session comm.IUserSession, dailytaskid int boxchange bool ) - defer func() { - session.Push() - this.PutUserSession(session) - }() - results = make(map[int32][]int32) for _, v := range this.configure.getdesTask(1) { alltasks[v.Key] = v From ac608e99a2c00a9d6bc83b878332219b3a9ad8dd Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 18 Sep 2023 19:09:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/battle/configure.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/modules/battle/configure.go b/modules/battle/configure.go index 73ec401fe..2aca2452f 100644 --- a/modules/battle/configure.go +++ b/modules/battle/configure.go @@ -94,7 +94,8 @@ func (this *configureComp) GetMonsterFormat(id int32) (result []*cfg.GameMonster if result, ok = this.mformat[id]; ok { return } - err = fmt.Errorf("GetMonsterFormat no found :%d", id) + // err = fmt.Errorf("GetMonsterFormat no found :%d", id) + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_monsterformat, id) this.module.Errorln(err) return } @@ -128,6 +129,7 @@ func (this *configureComp) getPandamasBuff(id int32) (configure *cfg.GamePandama } else { if configure, ok = v.(*cfg.GamePandamasBuff).GetDataMap()[id]; !ok { // err = fmt.Errorf("not found:%d ", id) + // err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_pandamasbuff, id) err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_pandamasbuff, id) this.module.Errorln(err) return @@ -146,7 +148,8 @@ func (this *configureComp) Getequipsuit(id int32) (result *cfg.GameEquipSuitData this.module.Errorln(err) } else { if result, ok = v.(*cfg.GameEquipSuit).GetDataMap()[id]; !ok { - err = fmt.Errorf("on found Getequipsuit:%d", id) + // err = fmt.Errorf("on found Getequipsuit:%d", id) + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_equipsuit, id) this.module.Errorln(err) } } @@ -163,7 +166,8 @@ func (this *configureComp) GetBattlereadyCapskill(id int32) (result *cfg.GameBat this.module.Errorln(err) } else { if result, ok = v.(*cfg.GameBattleready_capskill).GetDataMap()[id]; !ok { - err = fmt.Errorf("on found BattlereadyCapskill:%d", id) + // err = fmt.Errorf("on found BattlereadyCapskill:%d", id) + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_battleready_capskill, id) this.module.Errorln(err) } } @@ -177,6 +181,7 @@ func (this *configureComp) GetSkillAtk(skillId int32, skillLv int32) (result *cf return } } + // err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_skillafteratk, skillId) err = fmt.Errorf("no found SkillAtk skillId:%d skillLv%d", skillId, skillLv) this.module.Errorln(err.Error()) return @@ -192,7 +197,8 @@ func (this *configureComp) GetSkillAfteratk(skillId int32) (result *cfg.GameSkil this.module.Errorln(err) } else { if result, ok = v.(*cfg.GameSkillAfteratk).GetDataMap()[skillId]; !ok { - err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId) + // err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId) + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_skillafteratk, skillId) this.module.Errorln(err.Error()) } } @@ -209,7 +215,8 @@ func (this *configureComp) GetSkillBuff(skillId int32) (result *cfg.GameSkillBuf this.module.Errorln(err) } else { if result, ok = v.(*cfg.GameSkillBuff).GetDataMap()[skillId]; !ok { - err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId) + // err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId) + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_skillbuff, skillId) this.module.Errorln(err.Error()) } } @@ -226,7 +233,8 @@ func (this *configureComp) GetSkillPassive(skillId int32) (result *cfg.GameSkill this.module.Errorln(err) } else { if result, ok = v.(*cfg.GameSkillPassive).GetDataMap()[skillId]; !ok { - err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId) + // err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId) + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_skillpassive, skillId) this.module.Errorln(err.Error()) } } @@ -242,7 +250,7 @@ func (this *configureComp) GetBattleTask(battle int32) (result *cfg.GameBattleta this.module.Errorln(err) } else { if result, ok = v.(*cfg.GameBattletasktesting).GetDataMap()[battle]; !ok { - err = fmt.Errorf("on found GetBattleTask battle:%d", battle) + err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_battletasktesting, battle) this.module.Errorln(err.Error()) } }