From ca4f0faed51ea7940538253d0a8049302620150e Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 26 Sep 2023 13:42:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=86=E5=85=B8=E6=B4=BB=E5=8A=A8=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/activity/model_hdlist.go | 4 +- modules/activity/module.go | 93 +++++++++++++------------------- 2 files changed, 40 insertions(+), 57 deletions(-) diff --git a/modules/activity/model_hdlist.go b/modules/activity/model_hdlist.go index 0c31f72fa..72197490a 100644 --- a/modules/activity/model_hdlist.go +++ b/modules/activity/model_hdlist.go @@ -86,7 +86,7 @@ func (this *modelHdList) getHdInfoByType(itype pb.HdType) (activity *pb.DBHuodon activity, ok = this.activity[itype] this.hlock.RUnlock() if ok { - return nil + return } - return nil + return } diff --git a/modules/activity/module.go b/modules/activity/module.go index 43f72cbea..5a56a551b 100644 --- a/modules/activity/module.go +++ b/modules/activity/module.go @@ -12,7 +12,6 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/sys/configure" "go_dreamfactory/sys/db" - "go_dreamfactory/utils" "go.mongodb.org/mongo-driver/bson" ) @@ -206,41 +205,41 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32, update := make(map[string]interface{}) bChange := false // 查询玩家活动记录 - if data, err := this.modelhdData.getHddataByOid(session.GetUserId(), activity.Id); err == nil { + if list, err := this.modelhdData.getHddataByOid(session.GetUserId(), activity.Id); err == nil { // 注意 Gotarr:map[int32]int32 key value 已经挑战的次数 - if !utils.IsToday(data.Lasttime) { // 不是今天重置 - data.Lasttime = configure.Now().Unix() - data.Gotarr = make(map[int32]int32) - // 计算进度 - data.Val = int32((configure.Now().Unix()-activity.Stime)/24*3600) + 1 - update["lasttime"] = data.Lasttime - update["val"] = data.Val - update["gotarr"] = data.Gotarr - bChange = true - } - if data.Val == 0 { - var pos int32 + + if list.Lasttime < configure.Now().Unix() || list.Val == 0 { // 不是今天重置 + list.Gotarr = make(map[int32]int32) + update := make(map[string]interface{}) + + update["gotarr"] = list.Gotarr var maxday int32 _days := this.configure.GetHDCelebrationData() for _, v := range _days { // 开启循环 maxday += v } + var pos int32 _sub := int32((configure.Now().Unix() - activity.Stime) / (24 * 3600)) - _sub = _sub%maxday + 1 + for index, v := range _days { + find := false for i := 0; i < int(v); i++ { pos++ - if _sub == pos { - data.Val = int32(index) + 1 // 计算val 值 - update["val"] = data.Val + if _sub%maxday+1 == pos { + list.Val = int32(index) + 1 // 计算val 值 + update["val"] = list.Val + find = true break } } + if find { // 找到剩余的天数 + list.Lasttime = activity.Stime + int64(_sub+pos%v+1)*24*3600 + update["lasttime"] = list.Lasttime + break + } } - data.Val = 1 } - - if conf, err := this.configure.GetHDCelebration(data.Val); err == nil { + if conf, err := this.configure.GetHDCelebration(list.Val); err == nil { for _, v1 := range conf.Bosstype { if v1 == 0 { // bosstype 为0 表示所有的boss 类型都算 bosstype = 0 @@ -248,7 +247,7 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32, } } if conf.Systemtype == systemtype { - data.Gotarr[bosstype] += 1 + list.Gotarr[bosstype] += 1 // 天数 var idays int32 for i, v1 := range conf.Bosstype { @@ -258,9 +257,9 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32, } } // 更新信息 - update["gotarr"] = data.Gotarr + update["gotarr"] = list.Gotarr bChange = true - if data.Gotarr[bosstype] <= idays { + if list.Gotarr[bosstype] <= idays { bDouble = true } } @@ -268,9 +267,9 @@ func (this *Activity) HDCelebration(session comm.IUserSession, systemtype int32, if bChange { var sz []*pb.DBActivityData - this.modelhdData.ModifyActivityList(session.GetUserId(), data.Id, update) + this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update) // 推送活动数据进度变化 - sz = append(sz, data) + sz = append(sz, list) session.SendMsg(string(this.GetType()), "datachange", &pb.ActivityDataChangePush{ Data: sz, }) @@ -294,42 +293,19 @@ func (this *Activity) GetHdData(session comm.IUserSession, oids []string) (resul continue } } - if activity.Itype == pb.HdType_HdCelebration || activity.Itype == pb.HdType_HdLevel || activity.Itype == pb.HdType_HdTypeSign { + if activity.Itype == pb.HdType_HdCelebration { list, _ = this.modelhdData.getHddataByOid(session.GetUserId(), id) - if activity.Itype == pb.HdType_HdTypeSign { - if list.Val == 0 || !utils.IsToday(list.Lasttime) { - list.Lasttime = curTime - list.Val += 1 - update := make(map[string]interface{}) - update["lasttime"] = list.Lasttime - update["val"] = list.Val - this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update) - } - } - // 开服等级活动 - if activity.Itype == pb.HdType_HdLevel { - if user, err := this.ModuleUser.GetUser(session.GetUserId()); err == nil { - if list.Val != user.Lv { - list.Val = user.Lv - list.Lasttime = curTime - update := make(map[string]interface{}) - update["lasttime"] = list.Lasttime - update["val"] = list.Val - this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update) - } - } - } + // 获取开服庆典活动 if activity.Itype == pb.HdType_HdCelebration { // key := fmt.Sprintf("%s-%s", session.GetUserId(), id) if list, err = this.modelhdData.getHddataByOid(session.GetUserId(), id); err == nil { - if !utils.IsToday(list.Lasttime) || list.Val == 0 { // 不是今天重置 - list.Lasttime = configure.Now().Unix() + if list.Lasttime < configure.Now().Unix() || list.Val == 0 { // 不是今天重置 + //list.Lasttime = configure.Now().Unix() list.Gotarr = make(map[int32]int32) update := make(map[string]interface{}) // 计算进度 - update["lasttime"] = list.Lasttime update["gotarr"] = list.Gotarr var maxday int32 @@ -339,16 +315,23 @@ func (this *Activity) GetHdData(session comm.IUserSession, oids []string) (resul } var pos int32 _sub := int32((configure.Now().Unix() - activity.Stime) / (24 * 3600)) - _sub = _sub%maxday + 1 + for index, v := range _days { + find := false for i := 0; i < int(v); i++ { pos++ - if _sub == pos { + if _sub%maxday+1 == pos { list.Val = int32(index) + 1 // 计算val 值 update["val"] = list.Val + find = true break } } + if find { // 找到剩余的天数 + list.Lasttime = activity.Stime + int64(_sub+pos%v+1)*24*3600 + update["lasttime"] = list.Lasttime + break + } } this.modelhdData.ModifyActivityList(session.GetUserId(), list.Id, update) }