lt 11 ماه پیش
والد
کامیت
112f34123a
1فایلهای تغییر یافته به همراه60 افزوده شده و 4 حذف شده
  1. 60 4
      RO_Server_Trunk-branch_0.1.39/roserver/game/model/role_tower.go

+ 60 - 4
RO_Server_Trunk-branch_0.1.39/roserver/game/model/role_tower.go

@@ -1,9 +1,11 @@
 package model
 
 import (
+	"rocommon/service"
 	"rocommon/util"
 	"roserver/baseserver/model"
 	"roserver/serverproto"
+	"time"
 )
 
 const Refresh_Time_Gap = 6 * 60 * 60 //暂定6个小时刷新
@@ -26,6 +28,11 @@ type RoleTower struct {
 	nowTowerWjLevel    int32
 	nowTowerWjPassTime int64
 	boss               []int32 //无尽模式当前关卡boss
+	buff1              int32
+	buff2              int32
+	buff3              int32
+	refreshTowerWj     int64 //排行榜刷新时间
+	duration           int32 //周期
 
 	RushRound        int32
 	RushFightCount   int32
@@ -88,10 +95,10 @@ func (this *RoleTower) Load(msg interface{}) bool {
 			this.SetDirty(true)
 		}
 		//无尽模式初始化第一层boss
-		if len(proRole.RoleTower.Boss) == 0 {
-			if this.nowTowerWjLevel == 0 {
-				this.nowTowerWjLevel = 1
-			}
+		if this.nowTowerWjLevel == 0 {
+			this.nowTowerWjLevel = 1
+			this.duration = 1
+			this.TowerRefreshRankTime()
 			this.TowerBossRandom()
 			this.SetDirty(true)
 		}
@@ -112,6 +119,47 @@ func (this *RoleTower) TowerBossRandom() {
 	}
 }
 
+func (this *RoleTower) TowerRefreshRankTime() {
+	if this.refreshTowerWj == 0 {
+
+		//服务器开服时间
+		serverTime := service.GetServiceStartupTime() / 1000
+		t := time.Unix(int64(serverTime), 0)
+
+		// 3. 获取星期几(Weekday 返回 time.Weekday 类型)
+		weekday := t.Weekday()
+		//获取下周星期weekday的时间戳作为排行榜刷新时间
+		this.refreshTowerWj = getNextWeekdayAt23PM(weekday)
+	} else {
+		//每七天刷新
+		this.refreshTowerWj = this.refreshTowerWj + 7*86400
+
+	}
+
+}
+
+func getNextWeekdayAt23PM(targetWeekday time.Weekday) int64 {
+	now := time.Now()
+
+	// 计算当前时间到下周 targetWeekday 的天数差
+	daysUntilNext := (int(targetWeekday) - int(now.Weekday()) + 7) % 7
+	if daysUntilNext == 0 {
+		daysUntilNext = 7 // 如果今天就是目标星期几,则直接跳到下周
+	}
+
+	// 计算下周目标日期的 23:00:00
+	nextWeekdayTime := now.AddDate(0, 0, daysUntilNext)
+	nextWeekdayAt23PM := time.Date(
+		nextWeekdayTime.Year(),
+		nextWeekdayTime.Month(),
+		nextWeekdayTime.Day(),
+		23, 0, 0, 0, // 23:00:00
+		nextWeekdayTime.Location(),
+	)
+
+	return nextWeekdayAt23PM.Unix()
+}
+
 func (this *RoleTower) OnlineProcess() {
 	//圣典优化 后,玩家第一次查询保底奖励,根据this.RushRound作为最后一轮未领取的奖励
 	//保底战斗次数为0 表示,已经领取过奖励.
@@ -152,6 +200,14 @@ func (this *RoleTower) Save() {
 	saveMsg.Tower.SysRewardTime = this.SysRewardTime
 	saveMsg.Tower.NowTowerLevel = this.nowTowerLevel
 	saveMsg.Tower.NowTowerTime = this.nowTowerPassTime
+	saveMsg.Tower.NowTowerWjLevel = this.nowTowerWjLevel
+	saveMsg.Tower.NowTowerWjTime = this.nowTowerWjPassTime
+	saveMsg.Tower.Boss = this.boss
+	saveMsg.Tower.RefreshTowerWj = this.refreshTowerWj
+	saveMsg.Tower.Duration = this.duration
+	saveMsg.Tower.Buff1 = this.buff1
+	saveMsg.Tower.Buff2 = this.buff2
+	saveMsg.Tower.Buff3 = this.buff3
 	saveMsg.Tower.RushTower = &serverproto.RushTower{
 		RushRound:  this.RushRound,
 		Count:      this.RushFightCount,