Blame view

src/models/RoleTimeReset.lua 4.04 KB
cfd68b3a   zhouhaihai   时间重置 新逻辑
1
2
3
4
5
6
  local RoleTimeReset = {}
  
  RoleTimeReset.bind = function (Role)
  
  -- 重置内容 对应 GlobalVar TimeReset
  local ResetFunc = {}
ea40710f   zhouhaihai   活动
7
8
9
  ResetFunc["CrossDay"] = function(self, notify, response, now)
  	self.activity:checkActivityStatus(now, true, notify)
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
10
11
  	self.dailyData:refreshDailyData(notify)
  	self.dinerData:refreshDailyData(notify)
ea40710f   zhouhaihai   活动
12
  	self.activity:refreshDailyData(notify)
fb3d084d   liuzujun   月卡赛季卡发送邮件奖励
13
  	self.storeData:onCrossDay()
cfd68b3a   zhouhaihai   时间重置 新逻辑
14
15
  
  	self:setProperty("dTask", {})
aa74d6ef   zhouhaihai   掉落反馈
16
  	self:incrProperty("lday", 1)
8b65a363   zhouhaihai   优化
17
  	self:advRandomSupportEffect(not notify)
cfd68b3a   zhouhaihai   时间重置 新逻辑
18
  
bd4fb541   zhouhaihai   增加物品过期系统
19
  	self:checkExpireItem(not notify)
36875ec5   zhouhaihai   宝藏怪
20
21
22
23
24
  	local advMine = self:getProperty("advMine")
  	if advMine[1] then
  		advMine[1].co = nil
  	end
  	self:setProperty("advMine", advMine)
bd4fb541   zhouhaihai   增加物品过期系统
25
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
26
27
  	response.dTask = {}
  	response.advSup = self:getProperty("advSup")
2f7891b4   zhouhaihai   运营需要
28
  	self:log("onLogin")
cfd68b3a   zhouhaihai   时间重置 新逻辑
29
30
31
  end
  
  ResetFunc["CrossWeek"] = function(self, notify, response)
36875ec5   zhouhaihai   宝藏怪
32
33
34
35
  	local advMine = self:getProperty("advMine")
  	if advMine[2] then
  		advMine[2].co = nil
  	end
cfd68b3a   zhouhaihai   时间重置 新逻辑
36
37
38
  	self:setProperties({
  		wTask =  {}, 
  		dinerS = {},
36875ec5   zhouhaihai   宝藏怪
39
  		advMine = advMine,
cfd68b3a   zhouhaihai   时间重置 新逻辑
40
  	})
36875ec5   zhouhaihai   宝藏怪
41
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
42
43
44
45
  	response.wTask = {}
  	response.dinerS = {}
  end
  
7f9f002d   liuzujun   循环周活动
46
47
48
  ResetFunc["CrossMonth"] = function(self, notify, response)
  	local ltime = self:getProperty("ltime")
  	if isCrossMonth(ltime, skynet.timex()) then
7f9f002d   liuzujun   循环周活动
49
50
51
52
  		self.storeData:resetStoreReored(3)		--商店跨月重置 time_reset表关联id
  	end
  end
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
53
54
55
56
57
58
59
60
61
62
  
  ResetFunc["DinerRank"] = function(self, notify, response)
  	self.dinerData:rankResetData(notify)
  end
  
  ResetFunc["PvpShop"] = function(self, notify, response)
  	self:setProperty("pvpShop", {})
  	response.pvpShop = {}
  end
  
e3c5cc5e   zhouhaihai   跨服竞技场over
63
64
65
66
  ResetFunc["PvpCross"] = function(self, notify, response)
  	self:setProperty("pvpBet", {})
  end
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
67
68
69
70
71
72
73
74
  
  function Role:updateTimeReset(now, notify)
  	local timeReset = self:getProperty("timeReset")
  
  	local passTime = now - START_RESET_TIME
  
  	local needResetId = {}
  	for resetId, resetData in pairs(csvdb["time_resetCsv"]) do
7f9f002d   liuzujun   循环周活动
75
76
77
78
79
  		if resetData.interval > 0 then
  			local curRound = math.floor((passTime - resetData.start) / resetData.interval)
  			if not timeReset[resetId] or curRound ~= timeReset[resetId] then
  				needResetId[resetId] = curRound
  			end
cfd68b3a   zhouhaihai   时间重置 新逻辑
80
81
82
83
  		end
  	end
  	if not next(needResetId) then return end
  
ea40710f   zhouhaihai   活动
84
85
  	local resetMode = {}
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
86
87
88
  	local response = {}
  	for funcName, resetId in pairs(TimeReset) do
  		if needResetId[resetId] and ResetFunc[funcName] then
ea40710f   zhouhaihai   活动
89
90
  			ResetFunc[funcName](self, notify, response, now)
  			resetMode[funcName] = true
cfd68b3a   zhouhaihai   时间重置 新逻辑
91
  		end
1a0b3c56   liuzujun   抽卡保底,切换定向卡池
92
93
94
95
  		if needResetId[resetId] then
  			-- 充值商城购买记录
  			self.storeData:resetStoreReored(resetId)
  		end
cfd68b3a   zhouhaihai   时间重置 新逻辑
96
97
98
99
100
  	end
  
  	for resetId, round in pairs(needResetId) do
  		timeReset[resetId] = round
  	end
75614d9f   zhouhaihai   修改 修改 ltime 时机
101
102
  	self:setProperties({timeReset = timeReset, ltime = now})
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
103
  	response.timeReset = timeReset
f7a55da3   liuzujun   新增cb2临时限时礼包
104
  	response.ltime = now
cfd68b3a   zhouhaihai   时间重置 新逻辑
105
106
107
108
  
  	if notify then
  		self:notifyUpdateProperties(response)
  	end
ea40710f   zhouhaihai   活动
109
  	return resetMode
cfd68b3a   zhouhaihai   时间重置 新逻辑
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
  end
  
  -- 持续时间取  min(interval, duration) duration 填 0 默认使用 interval 作为持续时间
  local function getTimeResetDuration(rtype)
  	local resetData = csvdb["time_resetCsv"][rtype]
  	if not resetData then return 0 end
  	return resetData.duration == 0 and resetData.interval or math.min(resetData.interval, resetData.duration)
  end
  
  --检查功能是否是在开放期
  function Role:isTimeResetOpen(rtype)
  	local resetData = csvdb["time_resetCsv"][rtype]
  	if not resetData or getTimeResetDuration(rtype) >= resetData.interval then
  		return true
  	end
  	
  	return self:getTimeResetEndTime(rtype) > skynet.timex()
  end
  
  -- 当前轮次 开始时间
  function Role:getTimeResetStartTime(rtype)
  	local timeReset = self:getProperty("timeReset")
  	if not timeReset[rtype] then return 0 end
  	local resetData = csvdb["time_resetCsv"][rtype]
  	if not resetData then return 0 end
  	return START_RESET_TIME + timeReset[rtype] * resetData.interval + resetData.start
  end
  
  -- 当前轮次 结束时间
  function Role:getTimeResetEndTime(rtype)
  	return self:getTimeResetStartTime(rtype) + getTimeResetDuration(rtype)
  end
  
  function Role:getTimeResetRound(rtype)
  	local timeReset = self:getProperty("timeReset")
  	return timeReset[rtype] or 0
  end
  
  function Role:getTimeResetDataStart(rtype)
  	local resetData = csvdb["time_resetCsv"][rtype]
  	if not resetData then return 0 end
  	return resetData.start
  end
  
  
  
  
  
  
  
  end
  
  
  
  
  
  return RoleTimeReset