From 74ce02f26a95330a5ecadff8e3c48cbbfc5acc2a Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 5 Jul 2023 18:35:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/viking/api_ranklist.go | 1 + modules/viking/module.go | 50 ++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/modules/viking/api_ranklist.go b/modules/viking/api_ranklist.go index 612208715..8ffc1975b 100644 --- a/modules/viking/api_ranklist.go +++ b/modules/viking/api_ranklist.go @@ -31,6 +31,7 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.VikingRankListR return // 参数校验失败直接返回 } conn, _ := db.Local() + dbModel := db.NewDBModel(comm.TableVikingRank, 0, conn) if !req.Friend { var ( diff --git a/modules/viking/module.go b/modules/viking/module.go index 35632977f..98302e0bc 100644 --- a/modules/viking/module.go +++ b/modules/viking/module.go @@ -15,6 +15,7 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" "go_dreamfactory/sys/db" "math" "strconv" @@ -33,6 +34,11 @@ type Viking struct { service base.IRPCXService } +const ( + Cycle int32 = 14 // 持续14天 + Continued int32 = 30 +) + func NewModule() core.IModule { return &Viking{} } @@ -75,6 +81,7 @@ func (this *Viking) Start() (err error) { } this.battle = module.(comm.IBattle) + return } @@ -370,16 +377,47 @@ func (this *Viking) CheckBattelParameter(session comm.IUserSession, battle *pb.B } // 检查当前赛季是在本服还是在跨服 -func (this *Viking) CheckSeasonData() (bLocal bool) { +func (this *Viking) CheckCurSeasonData() (bLocal bool) { openTime := this.service.GetOpentime().Unix() this.Debugf("%d", openTime) - // 获取第一个赛季结束的时间 - endSeasonTime := utils.GetTodayZeroTime(openTime) + int64((7-this.service.GetOpentime().Day())*3600*24) + endSeasonTime := utils.GetTodayZeroTime(openTime) //+ int64((6-d)*3600*24) this.Debugf("%d", endSeasonTime) - // 校验是否过了一个月 - openTime = openTime + 30*3600*24 - // 第三个赛季 + var c int32 + if Continued%Cycle == 0 { + c = Continued / Cycle + } else { + c = Continued/Cycle + 1 + } + + // 只需判断当前时间是否大于第c个赛季即可 + endSeasonTime += 14 * 3600 * 24 * int64(c) + if endSeasonTime <= configure.Now().Unix() { + return false + } + return true +} + +// 检查上一个赛季实在本服还是在跨服 +func (this *Viking) CheckPreSeasonData() (bLocal bool) { + openTime := this.service.GetOpentime().Unix() + this.Debugf("%d", openTime) + // 获取第一个赛季结束的时间 + endSeasonTime := utils.GetTodayZeroTime(openTime) //+ int64((6-d)*3600*24) + this.Debugf("%d", endSeasonTime) + + var c int32 + if Continued%Cycle == 0 { + c = Continued / Cycle + } else { + c = Continued/Cycle + 1 + } + + // 只需判断当前时间是否大于第c个赛季即可 + endSeasonTime += 3600 * 24 * int64(Cycle*c) + if endSeasonTime <= configure.Now().Unix()-int64(Cycle*3600*24) { + return false + } return true }