Blame view

src/models/RoleTimeReset.lua 5.29 KB
cfd68b3a   zhouhaihai   时间重置 新逻辑
1
2
3
4
5
6
  local RoleTimeReset = {}
  
  RoleTimeReset.bind = function (Role)
  
  -- 重置内容 对应 GlobalVar TimeReset
  local ResetFunc = {}
ea40710f   zhouhaihai   活动
7
  ResetFunc["CrossDay"] = function(self, notify, response, now)
115454c1   liuzujun   调整咵天清日常与活动初始化的调用顺序
8
  	self:setProperty("dTask", {})
ea40710f   zhouhaihai   活动
9
10
  	self.activity:checkActivityStatus(now, true, notify)
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
11
12
  	self.dailyData:refreshDailyData(notify)
  	self.dinerData:refreshDailyData(notify)
ea40710f   zhouhaihai   活动
13
  	self.activity:refreshDailyData(notify)
fb3d084d   liuzujun   月卡赛季卡发送邮件奖励
14
  	self.storeData:onCrossDay()
cfd68b3a   zhouhaihai   时间重置 新逻辑
15
  
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
  
ff692d37   zhouhaihai   跨月
26
27
28
29
30
  	local ltime = self:getProperty("ltime")
  	if isCrossMonth(ltime, now) then
  		self.storeData:resetStoreReored(3)		--商店跨月重置 time_reset表关联id 
  	end
  
a5dc3b0e   chenyueqi   回归活动初版
31
  	-- 检查回归者
7a0dc1cf   chenyueqi   初始号不触发回归活动
32
  	if ltime ~= 0 and (now - ltime) >= 86400 * globalCsv.returner_time then
a5dc3b0e   chenyueqi   回归活动初版
33
34
35
  		self:checkReturner()
  	end
  
29fbbc10   zhouhaihai   夜间打工
36
  	-- 检查 夜间打工
0e3acc50   liguanghui   roleTImeReset的rol...
37
  	local workBattle = self:getProperty("workBattle")
29fbbc10   zhouhaihai   夜间打工
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  	local need = {}
  	for i = 1, 5 do
  		if workBattle[i] == 1 then
  			need[#need + 1] = workBattle.round * 10 + i
  		end
  	end
  	local change = false
  	if next(need) then
  		local ret = redisproxy:hmget(WORK_BATTLE_COUNT, table.unpack(need))
  		for idx, v in ipairs(need) do
  			local ctype = v % 10
  			local ccount = tonum(ret[idx])
  			local workMainCsv = csvdb["work_mainCsv"][ctype]
  			if ccount >= workMainCsv.target_num then 
  				self:sendMail(workMainCsv.email, nil, workMainCsv.phase_award)
  			end
  			workBattle[ctype] = -1
  		end
  		change = true
  	end
  	local newRound = math.floor((now - START_RESET_TIME) / 604800)
  	if newRound ~= workBattle.round then
  		workBattle = {round = newRound}
  		change = true
  	end
  	if change then
  		self:setProperty("workBattle", workBattle)
  		response.workBattle = workBattle
  	end
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
68
69
  	response.dTask = {}
  	response.advSup = self:getProperty("advSup")
2f7891b4   zhouhaihai   运营需要
70
  	self:log("onLogin")
c0308568   zhangqijia   fix: 跨天登录才计登录天数
71
72
73
  
  	--跨天登录,登录次数+1
  	self:checkTaskEnter("Login", {})
cfd68b3a   zhouhaihai   时间重置 新逻辑
74
75
76
  end
  
  ResetFunc["CrossWeek"] = function(self, notify, response)
36875ec5   zhouhaihai   宝藏怪
77
78
79
80
  	local advMine = self:getProperty("advMine")
  	if advMine[2] then
  		advMine[2].co = nil
  	end
cfd68b3a   zhouhaihai   时间重置 新逻辑
81
82
83
  	self:setProperties({
  		wTask =  {}, 
  		dinerS = {},
36875ec5   zhouhaihai   宝藏怪
84
  		advMine = advMine,
cfd68b3a   zhouhaihai   时间重置 新逻辑
85
  	})
36875ec5   zhouhaihai   宝藏怪
86
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
87
88
  	response.wTask = {}
  	response.dinerS = {}
dfa9ae5e   liuzujun   战令任务活动
89
90
  
  	self.activity:refreshWeekData(notify)
cddfa602   zhangqijia   feat: 月卡解锁的日/周商店随...
91
  	self.storeData:refreshWeekData(notify)
40b19300   chenyueqi   电波塔激活加成效果后对各个系统的加成
92
93
94
95
96
97
  
  	-- 跨周送一些道具
  	local BnousReward = self:getBnousPvpTicket()
  	if next(BnousReward) then
  		local reward, change = self:award(BnousReward, {log = {desc = "towerBnous"}})
  	end
cfd68b3a   zhouhaihai   时间重置 新逻辑
98
99
  end
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
100
101
102
103
104
105
106
107
108
109
  
  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
110
111
112
113
  ResetFunc["PvpCross"] = function(self, notify, response)
  	self:setProperty("pvpBet", {})
  end
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
114
115
116
117
118
119
120
121
  
  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   循环周活动
122
123
124
125
126
  		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   时间重置 新逻辑
127
128
129
130
  		end
  	end
  	if not next(needResetId) then return end
  
ea40710f   zhouhaihai   活动
131
132
  	local resetMode = {}
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
133
  	local response = {}
c2e24956   liuzujun   战令-周任务没有刷新, 日活跃签到...
134
135
136
137
138
139
140
141
  	for idx = 1, #TimeResetArray do
  		local funcName = TimeResetArray[idx]
  		local resetId = TimeReset[funcName]
  		if resetId then
  			if needResetId[resetId] and ResetFunc[funcName] then
  				ResetFunc[funcName](self, notify, response, now)
  				resetMode[funcName] = true
  			end
cfd68b3a   zhouhaihai   时间重置 新逻辑
142
  		end
cfd68b3a   zhouhaihai   时间重置 新逻辑
143
144
145
  	end
  
  	for resetId, round in pairs(needResetId) do
10020df6   zhouhaihai   跨天礼包重置
146
  		self.storeData:resetStoreReored(resetId)
cfd68b3a   zhouhaihai   时间重置 新逻辑
147
148
  		timeReset[resetId] = round
  	end
75614d9f   zhouhaihai   修改 修改 ltime 时机
149
150
  	self:setProperties({timeReset = timeReset, ltime = now})
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
151
  	response.timeReset = timeReset
f7a55da3   liuzujun   新增cb2临时限时礼包
152
  	response.ltime = now
cfd68b3a   zhouhaihai   时间重置 新逻辑
153
154
155
156
  
  	if notify then
  		self:notifyUpdateProperties(response)
  	end
ea40710f   zhouhaihai   活动
157
  	return resetMode
cfd68b3a   zhouhaihai   时间重置 新逻辑
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
  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