Blame view

src/models/RoleTimeReset.lua 3.13 KB
cfd68b3a   zhouhaihai   时间重置 新逻辑
1
2
3
4
5
6
7
8
9
10
11
  local RoleTimeReset = {}
  
  RoleTimeReset.bind = function (Role)
  
  -- 重置内容 对应 GlobalVar TimeReset
  local ResetFunc = {}
  ResetFunc["CrossDay"] = function(self, notify, response)
  	self.dailyData:refreshDailyData(notify)
  	self.dinerData:refreshDailyData(notify)
  
  	self:setProperty("dTask", {})
8b65a363   zhouhaihai   优化
12
  	self:advRandomSupportEffect(not notify)
cfd68b3a   zhouhaihai   时间重置 新逻辑
13
  
bd4fb541   zhouhaihai   增加物品过期系统
14
15
  	self:checkExpireItem(not notify)
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  	response.dTask = {}
  	response.advSup = self:getProperty("advSup")
  end
  
  ResetFunc["CrossWeek"] = function(self, notify, response)
  	self:setProperties({
  		wTask =  {}, 
  		dinerS = {},
  	})
  	response.wTask = {}
  	response.dinerS = {}
  end
  
  
  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
39
40
41
42
  ResetFunc["PvpCross"] = function(self, notify, response)
  	self:setProperty("pvpBet", {})
  end
  
cfd68b3a   zhouhaihai   时间重置 新逻辑
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  
  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
  		local curRound = math.floor((passTime - resetData.start) / resetData.interval)
  		if not timeReset[resetId] or curRound ~= timeReset[resetId] then
  			needResetId[resetId] = curRound
  		end
  	end
  	if not next(needResetId) then return end
  
  	local response = {}
  	for funcName, resetId in pairs(TimeReset) do
  		if needResetId[resetId] and ResetFunc[funcName] then
  			ResetFunc[funcName](self, notify, response)
  		end
  	end
  
  	for resetId, round in pairs(needResetId) do
  		timeReset[resetId] = round
  	end
  	self:setProperty("timeReset", timeReset)
  	response.timeReset = timeReset
  
  	if notify then
  		self:notifyUpdateProperties(response)
  	end
  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