From db953e2029a52afa249c0fcb519c5cec98027c02 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 29 Dec 2023 17:15:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Rtype77=20=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/viking/api_challengeover.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/viking/api_challengeover.go b/modules/viking/api_challengeover.go index d908cb86b..526a0ae4d 100644 --- a/modules/viking/api_challengeover.go +++ b/modules/viking/api_challengeover.go @@ -248,6 +248,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal tasks = append(tasks, comm.GetBuriedParam(comm.Rtype237, consumPs)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype201, consumPs)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype76, 1, req.BossId)) + tasks = append(tasks, comm.GetBuriedParam(comm.Rtype77, 1, req.BossId, req.Difficulty)) if bHelp { tasks = append(tasks, comm.GetBuriedParam(comm.Rtype180, req.BossId, 1)) } From 7b444d0be39de48e5fb695f5b43a8658d501232a Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 29 Dec 2023 17:56:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=8E=A9=E5=AE=B6?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 6 ++++ modules/friend/api_cross_getassist.go | 51 ++++++++++++++++++--------- modules/friend/module.go | 30 ++++++++++++++++ modules/user/api_create.go | 24 +++++++++++++ modules/user/module.go | 28 ++++++++------- 5 files changed, 110 insertions(+), 29 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index c217f7ba7..141f165f0 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -33,6 +33,11 @@ type ( IPayDelivery interface { Delivery(session IUserSession, pId int32) (errdata *pb.ErrorData, items []*pb.UserAtno) } + + // 修改玩家基本数据 + IUpdateUserBaseInfo interface { + UpdateUserBaseInfo(session IUserSession, info *pb.BaseUserInfo) (err error) + } ) /* @@ -274,6 +279,7 @@ type ( QiecuoFinishNotify(redUid, matchId string) error // 红点 IGetReddot + IUpdateUserBaseInfo } //聊天系统 diff --git a/modules/friend/api_cross_getassist.go b/modules/friend/api_cross_getassist.go index ec564f26d..20d467378 100644 --- a/modules/friend/api_cross_getassist.go +++ b/modules/friend/api_cross_getassist.go @@ -48,9 +48,9 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA } } leftCount = int32(comm.AssistHeroCount - len(list.Data)) - localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{}) - randomIndex := comm.GetRandNum(0, int32(localNum)) - cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(randomIndex)).SetLimit(int64(leftCount))) //.skip(1).limit(1) + // localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{}) + // randomIndex := comm.GetRandNum(0, int32(localNum)) + cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(leftCount))) //.skip(1).limit(1) for cur.Next(context.TODO()) { tmp := &pb.DBFriend{} if err = cur.Decode(tmp); err == nil { @@ -75,21 +75,40 @@ func (this *apiComp) GetAssistHero(session comm.IUserSession, req *pb.FriendGetA return } - for k := range list.Data { - uids = append(uids, k) - } - // 批量查 - friends, err = this.module.modelFriend.GetFriends(uids) - if err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_FriendSelfNoData, - Title: pb.ErrorCode_FriendSelfNoData.ToString(), + if len(list.Data) == 0 { // 异常处理 + leftCount = int32(comm.AssistHeroCount - len(list.Data)) + // localNum, _ := this.module.modelFriend.DB.CountDocuments(core.SqlTable(this.module.modelFriend.TableName), bson.M{}) + // randomIndex := comm.GetRandNum(0, int32(localNum)) + cur, err := this.module.modelFriend.DB.Find(core.SqlTable(this.module.modelFriend.TableName), bson.M{"assistHeroId": bson.M{"$ne": ""}}, options.Find().SetSkip(int64(0)).SetLimit(int64(leftCount))) //.skip(1).limit(1) + for cur.Next(context.TODO()) { + tmp := &pb.DBFriend{} + if err = cur.Decode(tmp); err == nil { + list.Data[tmp.Uid] = tmp.Info.Name + heros = append(heros, tmp.Hero) + } + } + + err = this.module.modelAssist.modifyAssistData(session.GetUserId(), map[string]interface{}{ + "data": list.Data, + }) + } else { + for k := range list.Data { + uids = append(uids, k) + } + // 批量查 + friends, err = this.module.modelFriend.GetFriends(uids) + if err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_FriendSelfNoData, + Title: pb.ErrorCode_FriendSelfNoData.ToString(), + } + return + } + for _, v := range friends { + heros = append(heros, v.Hero) } - return - } - for _, v := range friends { - heros = append(heros, v.Hero) } + session.SendMsg(string(this.module.GetType()), "getassisthero", &pb.FriendGetAssistHeroResp{ Data: list, Hero: heros, diff --git a/modules/friend/module.go b/modules/friend/module.go index 74991cd67..6d9116479 100644 --- a/modules/friend/module.go +++ b/modules/friend/module.go @@ -6,10 +6,12 @@ package friend import ( "context" "errors" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" + "go_dreamfactory/sys/db" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" @@ -252,3 +254,31 @@ func (this *Friend) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (r return } + +func (this *Friend) UpdateUserBaseInfo(session comm.IUserSession, info *pb.BaseUserInfo) (err error) { + + if db.IsCross() { + err = this.modelFriend.Change(session.GetUserId(), map[string]interface{}{ + "info": info, + }) + } else { + var ( + model *db.DBModel + conn_ *db.DBConn + ) + // 跨服 + conn_, err = db.Cross() // 获取跨服数据库对象 + if err != nil { + return + } + if model = db.NewDBModelByExpired(comm.TableFriend, conn_); model == nil { + err = fmt.Errorf("cand found table :%s,%v", comm.TableFriend, conn_) + return + } + err = model.Change(session.GetUserId(), map[string]interface{}{ + "info": info, + }) + } + + return +} diff --git a/modules/user/api_create.go b/modules/user/api_create.go index 926ebf64d..c2c557832 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -2,6 +2,7 @@ package user import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -92,6 +93,9 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e update["avatar"] = globalConf.GirlHeadPortrait } user.Gender = req.Gender + user.Name = req.NickName + user.CurSkin = req.Skin + user.Gender = req.Gender session.SetMate(comm.Session_User, user) if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil { errdata = &pb.ErrorData{ @@ -124,7 +128,27 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (e //异步逻辑 go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { + baseInfo := &pb.BaseUserInfo{ + Uid: user.Uid, + Sid: user.Sid, + Name: user.Name, + Gender: user.Gender, + Skin: user.CurSkin, + Aframe: user.Curaframe, + Title: user.Curtitle, + Lv: user.Lv, + } + for _, m := range this.module.notifyUserinfo { + i, err := this.service.GetModule(core.M_Modules(m)) + if err != nil { + this.module.Errorln(err) + continue + } + if ic, ok := i.(comm.IUpdateUserBaseInfo); ok { + ic.UpdateUserBaseInfo(session, baseInfo) + } + } this.mail.SendMailByCid(session, comm.Welcomemail, nil) if len(tasks) > 0 { this.module.ModuleBuried.TriggerBuried(session, tasks...) diff --git a/modules/user/module.go b/modules/user/module.go index bd8c56032..087755d75 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -52,19 +52,20 @@ func NewModule() core.IModule { type User struct { modules.ModuleBase - chat comm.IChat - api *apiComp - modelUser *ModelUser - modelSession *ModelSession - modelSetting *ModelSetting - modelExpand *ModelExpand - service base.IRPCXService - configure *configureComp - globalConf *cfg.GameGlobalData - modelSign *ModelSign // 签到 - timerLock sync.Mutex - timerMap map[string]*time.Ticker - reddot comm.IReddot + chat comm.IChat + api *apiComp + modelUser *ModelUser + modelSession *ModelSession + modelSetting *ModelSetting + modelExpand *ModelExpand + service base.IRPCXService + configure *configureComp + globalConf *cfg.GameGlobalData + modelSign *ModelSign // 签到 + timerLock sync.Mutex + timerMap map[string]*time.Ticker + reddot comm.IReddot + notifyUserinfo []string // userinfo change } func (this *User) GetType() core.M_Modules { @@ -107,6 +108,7 @@ func (this *User) Start() (err error) { return } this.reddot = module.(comm.IReddot) + this.notifyUserinfo = append(this.notifyUserinfo, string(comm.ModuleFriend)) // 只要涉及到更新userinof 信息的模块在此注册 return } From 4dd7f0f4eefa386e8f753f5bb67906632c8fbdd0 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 29 Dec 2023 21:34:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?gm=20=E8=B7=B3=E8=BF=87=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/sys/module.go | 5 +- modules/timer/activity.go | 124 ++++++++++++++++++-------------------- modules/timer/module.go | 2 +- 3 files changed, 63 insertions(+), 68 deletions(-) diff --git a/modules/sys/module.go b/modules/sys/module.go index c1cb24dd3..3d22699e1 100644 --- a/modules/sys/module.go +++ b/modules/sys/module.go @@ -171,7 +171,10 @@ func (this *ModuleSys) GMOpenAllCondition(uid string) { return } for _, v := range opencfg.GetDataList() { - list.Cond[v.Id] = 2 + if v.ActivateType != 1 { // 跳过手动激活类型 + list.Cond[v.Id] = 2 + } + } this.modelSys.ChangeOpenCondData(uid, map[string]interface{}{ "cond": list.Cond, diff --git a/modules/timer/activity.go b/modules/timer/activity.go index b50fffa9a..0f6b4d457 100644 --- a/modules/timer/activity.go +++ b/modules/timer/activity.go @@ -53,7 +53,7 @@ func (this *Activity) Start() (err error) { return } timer := time.NewTicker(time.Second * 1) - this.LoadActivityData("") + this.LoadActivityData() go func() { locp: @@ -70,72 +70,63 @@ func (this *Activity) Start() (err error) { //cron.AddFunc("0 0 0 ? * MON", this.TimerSeason) return } - -func (this *Activity) LoadActivityData(id string) { - if id == "" { // 查所有的 - if c, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{}); err == nil { - var ( - szEnd []string // 活动结束 - szStart []string // 有活动开启 - ) - this.hlock.Lock() - this.curActivity = make(map[pb.HdType]*pb.DBHuodong) - this.delActivity = make(map[pb.HdType]*pb.DBHuodong) - this.futureActivity = make(map[pb.HdType]*pb.DBHuodong) - defer this.hlock.Unlock() - for c.Next(context.Background()) { - hd := &pb.DBHuodong{} - if err = c.Decode(hd); err != nil { - this.module.Errorf("err:%v", err) - continue - } - if hd.Etime <= configure.Now().Unix() { - this.delActivity[hd.Itype] = hd - szEnd = append(szEnd, hd.Id) - } else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() { - this.curActivity[hd.Itype] = hd - szStart = append(szStart, hd.Id) - } else { - this.futureActivity[hd.Itype] = hd - } - } - if len(szEnd) > 0 { - this.NotifyActivityOver(szEnd) - } - if len(szStart) > 0 { - this.NotifyActivityStart(szStart) - } - } - } else { - var hd *pb.DBHuodong - if err := this.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": id}).Decode(&hd); err != nil { - return - } - if hd.Etime <= configure.Now().Unix() { // 活动结束 - this.NotifyActivityOver([]string{hd.Id}) - } else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() { - this.NotifyActivityStart([]string{hd.Id}) - } - this.hlock.Lock() - // 删除内存中 - if _, ok := this.curActivity[hd.Itype]; ok { - delete(this.curActivity, hd.Itype) - } - if _, ok := this.delActivity[hd.Itype]; ok { - delete(this.delActivity, hd.Itype) - } - if _, ok := this.futureActivity[hd.Itype]; ok { - delete(this.futureActivity, hd.Itype) - } - if hd.Etime <= configure.Now().Unix() { // 活动结束 - this.delActivity[hd.Itype] = hd - } else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() { - this.curActivity[hd.Itype] = hd - } else { - this.futureActivity[hd.Itype] = hd - } - defer this.hlock.Unlock() +func (this *Activity) ReLoadActivityData(id string) { + var hd *pb.DBHuodong + if err := this.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": id}).Decode(&hd); err != nil { + return } + if hd.Etime <= configure.Now().Unix() { // 活动结束 + this.NotifyActivityOver([]string{hd.Id}) + } else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() { + this.NotifyActivityStart([]string{hd.Id}) + } + this.hlock.Lock() + // 删除内存中 + if _, ok := this.curActivity[hd.Itype]; ok { + delete(this.curActivity, hd.Itype) + } + if _, ok := this.delActivity[hd.Itype]; ok { + delete(this.delActivity, hd.Itype) + } + if _, ok := this.futureActivity[hd.Itype]; ok { + delete(this.futureActivity, hd.Itype) + } + if hd.Etime <= configure.Now().Unix() { // 活动结束 + this.delActivity[hd.Itype] = hd + } else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() { + this.curActivity[hd.Itype] = hd + } else { + this.futureActivity[hd.Itype] = hd + } + defer this.hlock.Unlock() +} + +func (this *Activity) LoadActivityData() { + + if c, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{}); err == nil { + + this.hlock.Lock() + this.curActivity = make(map[pb.HdType]*pb.DBHuodong) + this.delActivity = make(map[pb.HdType]*pb.DBHuodong) + this.futureActivity = make(map[pb.HdType]*pb.DBHuodong) + defer this.hlock.Unlock() + for c.Next(context.Background()) { + hd := &pb.DBHuodong{} + if err = c.Decode(hd); err != nil { + this.module.Errorf("err:%v", err) + continue + } + if hd.Etime <= configure.Now().Unix() { + this.delActivity[hd.Itype] = hd + } else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() { + this.curActivity[hd.Itype] = hd + } else { + this.futureActivity[hd.Itype] = hd + } + } + + } + } func (this *Activity) NotifyActivityOver(szEnd []string) { @@ -167,6 +158,7 @@ func (this *Activity) NotifyActivityStart(szStart []string) { this.module.Errorln(err) } } + func (this *Activity) CheckActivityData() { var ( szEnd []string // 活动结束 diff --git a/modules/timer/module.go b/modules/timer/module.go index 2042cda44..28f4eaae9 100644 --- a/modules/timer/module.go +++ b/modules/timer/module.go @@ -101,7 +101,7 @@ func (this *Timer) getDBModelByUid(uid, tableName string) (model *db.DBModel, er // 重新加载活动数据 func (this *Timer) ReloadActivityData(id string) { - this.activity.LoadActivityData(id) + this.activity.ReLoadActivityData(id) } // 日志