|
@@ -1,9 +1,11 @@
|
|
|
package model
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "rocommon/service"
|
|
|
"rocommon/util"
|
|
"rocommon/util"
|
|
|
"roserver/baseserver/model"
|
|
"roserver/baseserver/model"
|
|
|
"roserver/serverproto"
|
|
"roserver/serverproto"
|
|
|
|
|
+ "time"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const Refresh_Time_Gap = 6 * 60 * 60 //暂定6个小时刷新
|
|
const Refresh_Time_Gap = 6 * 60 * 60 //暂定6个小时刷新
|
|
@@ -26,6 +28,11 @@ type RoleTower struct {
|
|
|
nowTowerWjLevel int32
|
|
nowTowerWjLevel int32
|
|
|
nowTowerWjPassTime int64
|
|
nowTowerWjPassTime int64
|
|
|
boss []int32 //无尽模式当前关卡boss
|
|
boss []int32 //无尽模式当前关卡boss
|
|
|
|
|
+ buff1 int32
|
|
|
|
|
+ buff2 int32
|
|
|
|
|
+ buff3 int32
|
|
|
|
|
+ refreshTowerWj int64 //排行榜刷新时间
|
|
|
|
|
+ duration int32 //周期
|
|
|
|
|
|
|
|
RushRound int32
|
|
RushRound int32
|
|
|
RushFightCount int32
|
|
RushFightCount int32
|
|
@@ -88,10 +95,10 @@ func (this *RoleTower) Load(msg interface{}) bool {
|
|
|
this.SetDirty(true)
|
|
this.SetDirty(true)
|
|
|
}
|
|
}
|
|
|
//无尽模式初始化第一层boss
|
|
//无尽模式初始化第一层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.TowerBossRandom()
|
|
|
this.SetDirty(true)
|
|
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() {
|
|
func (this *RoleTower) OnlineProcess() {
|
|
|
//圣典优化 后,玩家第一次查询保底奖励,根据this.RushRound作为最后一轮未领取的奖励
|
|
//圣典优化 后,玩家第一次查询保底奖励,根据this.RushRound作为最后一轮未领取的奖励
|
|
|
//保底战斗次数为0 表示,已经领取过奖励.
|
|
//保底战斗次数为0 表示,已经领取过奖励.
|
|
@@ -152,6 +200,14 @@ func (this *RoleTower) Save() {
|
|
|
saveMsg.Tower.SysRewardTime = this.SysRewardTime
|
|
saveMsg.Tower.SysRewardTime = this.SysRewardTime
|
|
|
saveMsg.Tower.NowTowerLevel = this.nowTowerLevel
|
|
saveMsg.Tower.NowTowerLevel = this.nowTowerLevel
|
|
|
saveMsg.Tower.NowTowerTime = this.nowTowerPassTime
|
|
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{
|
|
saveMsg.Tower.RushTower = &serverproto.RushTower{
|
|
|
RushRound: this.RushRound,
|
|
RushRound: this.RushRound,
|
|
|
Count: this.RushFightCount,
|
|
Count: this.RushFightCount,
|