Blame view

src/models/Activity.lua 47.3 KB
fa992c94   liuzujun   添加daily,diner,act...
1
  local Activity = class("Activity", require("shared.ModelBaseMysql"))
be4e8031   zhouhaihai   活动 拾荒
2
  local string_format = string.format
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
3
  
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
4
  -- activity_ctr showType
e51ff6d2   zhouhaihai   冒险~
5
  Activity.ActivityType = {
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
6
  	SsrUpPoolChange = 1,	-- 特定英雄活动,切卡池
706b517e   liuzujun   翻倍掉落活动,商城免费宝箱
7
  	DoubleDrop = 2, -- 双倍掉落
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
8
9
10
11
12
13
14
15
16
17
18
19
20
  	Sign = 4,  -- 签到
  	ChangeCG = 5,	-- 客户端使用,切换抽卡界面
  	PaySignIn = 6,	--付费签到
  	ExploreCommand = 7,	-- 探索指令
  	PayBack = 8,	--返利
  
  	BonusDouble = 9,	-- 奖励关卡翻倍
  	CalendaTask = 10,	-- 日历任务
  
  	FoodSell = 11,	--贩卖周 料理
  	DrawHero = 12,	--抽卡周 招募
  	AdvDraw = 13,	--拾荒抽周 资助
  	OpenBox = 14,	--拆解周 时钟箱
f7a55da3   liuzujun   新增cb2临时限时礼包
21
  	RaceDraw = 16,  -- 定向招募活动
847f9a7b   liuzujun   兑换活动,邮件内容修改
22
23
24
25
26
  
  	ChallengeLevel = 17,	-- 挑战关卡活动
  	Exchange = 18,	-- 兑换活动
  	HangDrop = 19,	-- 挂机掉落活动
  	Gachakon = 20,	-- 扭蛋活动
686d4fd6   liuzujun   兑换活动支持兑换多个, 新增卡池
27
28
29
  
  	WishHeroPool = 23, 	-- 心愿卡池
  	ActHeroPool = 24, -- 活动卡池
8e892c71   liuzujun   挑战关卡活动打完再扣门票
30
  	ActShopGoods = 25, 	-- 活动商品
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
31
  
161c50cc   zhouhaihai   宝藏怪活动
32
  	Crisis = 26, -- 宝藏怪活动
ac885527   liuzujun   联动签到活动
33
34
  
  	CommonSignIn = 28, 	--通用签到
cab7184b   chenyueqi   活动能量bug
35
  	FriendEnergy = 30, -- 好友互赠能量活动 
c756d4df   liuzujun   新年将军令活动
36
37
  	AdvLevel = 33,	-- 拾荒关卡
  	BattleCommand = 34, -- 战令活动
336fa4a6   chenyueqi   新的活动签到,新春三重奏之返还0消耗
38
39
  	NewSign = 36, -- 活动签到,单独的签到界面
  	HeroBackFree = 37, -- 无损耗归还
b620581a   liuzujun   战令活动,战令相关的任务活动
40
  
dfa9ae5e   liuzujun   战令任务活动
41
  	BattleCommandTask = 38, -- 战令任务活动
78e5b90e   liuzujun   完成需求:新玩家任务
42
  	NewUserTask = 41,		-- 新用户任务
0769908c   zhangqijia   feat: 常规世界boss
43
  	RegularWorldBoos = 42,	-- 常规世界boos
21581e1f   liuzujun   新增 电台类活动
44
  	RadioTask = 43,			-- 活动电台任务
161c50cc   zhouhaihai   宝藏怪活动
45
  }
9a1c54b2   zhouhaihai   活动
46
  
e51ff6d2   zhouhaihai   冒险~
47
48
49
50
  local function checkActivityType(activityType)
  	if type(activityType) == "string" then
  		activityType = Activity.ActivityType[activityType]
  	end
ea40710f   zhouhaihai   活动
51
  	return activityType or 0
e51ff6d2   zhouhaihai   冒险~
52
53
54
55
56
57
  end
  
  
  function Activity:ctor(properties)
  	Activity.super.ctor(self, properties)
  
9a1c54b2   zhouhaihai   活动
58
  	self._isOpen = {}
e51ff6d2   zhouhaihai   冒险~
59
  end
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
60
  
686d4fd6   liuzujun   兑换活动支持兑换多个, 新增卡池
61
62
63
64
65
66
67
  function Activity:getType(actType)
  	if type(actType) == "string" then
  		actType = Activity.ActivityType[actType]
  	end
  	return actType or 0
  end
  
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
68
  
e51ff6d2   zhouhaihai   冒险~
69
  Activity.schema = {
fa992c94   liuzujun   添加daily,diner,act...
70
  	id 			= {"number", 0, "pri"},		-- 角色id
be4e8031   zhouhaihai   活动 拾荒
71
  	actime 		= {"table", {}},  -- 最近检查某项活动的开始时间  {id = time}
7f9f002d   liuzujun   循环周活动
72
  	round		= {"table", {}},  -- 记录活动到了第几轮  {id = roundnum}
3df6d602   liuzujun   添加玩家签到天数字段
73
      signInDay   = {"number", 0},    -- 签到天数
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
74
  	act4		= {"table", {}},  -- {0 = day, 1= -1, 2 = -1} == 签到活动
ede282c0   liuzujun   付费签到规则改为按登录天数计算进度...
75
  	act6		= {"table", {}},  -- {0 = day, 1 = 1, 2 = 1} == 付费签到活动
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
76
77
78
79
80
81
  	act8		= {"number", 0},  -- 充值返利 
  
  	act11		= {"table", {}},  -- {0 = 贩卖数量, 1=1, 2=1}  贩卖周活动  1表示领取过该档位的奖励
  	act12		= {"table", {}},  -- {0 = 抽卡次数, 1=1, 2=1}  抽卡周活动  1表示领取过该档位的奖励
  	act13		= {"table", {}},  -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1}  拾荒周活动  1表示领取过该档位的奖励
  	act14		= {"table", {}},  -- {0 = 拆解数量, 1=1, 2=1}  拆解周活动  1表示领取过该档位的奖励
847f9a7b   liuzujun   兑换活动,邮件内容修改
82
  
b8b1c164   liuzujun   扭蛋活动,万能碎片bug
83
84
  	act17		= {"table", {}},	  -- {id=关卡星数, totalDmg=Boss总伤害}
  	act18		= {"table", {}, true},	  -- {id=兑换数量}
2bc706ab   liuzujun   兑换活动重置,累充功能
85
  	act19		= {"number", 0},	  -- {挂机信息}
b8b1c164   liuzujun   扭蛋活动,万能碎片bug
86
  	act20		= {"table", {}},	  -- {id=扭蛋抽出数量}
eb5ffd1c   liuzujun   世界boss翻牌奖励 活动卡池保底...
87
88
  
  	act24		= {"table", {}, true},	-- 活动卡池 {id=repaynum}
161c50cc   zhouhaihai   宝藏怪活动
89
  	act26 		= {"table", {}},	-- {task = {id = count}, socre = {id = status}}
ac885527   liuzujun   联动签到活动
90
91
  
  	act28		= {"table", {}},	-- 每日活跃签到 {0=day, 1=1,2=1,3=1}
cab7184b   chenyueqi   活动能量bug
92
  	act30 		= {"table", {}}, -- {magic = 0, limit = 0, reward = {id = 1, id = 1}, giveAE = {}, getAE = {}} 奖励字段1表示领取过奖励
c756d4df   liuzujun   新年将军令活动
93
  
98be031a   liuzujun   新年活动
94
95
  	act33 		= {"table", {}}, -- 拾荒关卡活动 {id={max=最大积分, pass=1}, r=""}
  
c756d4df   liuzujun   新年将军令活动
96
  	act34		= {"table", {}},	-- 战令记录{unlock = 1, freeR = "", payR = "", lvl = 10, sum = 100}
336fa4a6   chenyueqi   新的活动签到,新春三重奏之返还0消耗
97
  	act36 		= {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1}
0769908c   zhangqijia   feat: 常规世界boss
98
  	act42 		= {"table", {}}, --
386cd4c1   zhangqijia   feat: 狩猎祭,增加重置扭蛋机协议
99
100
  
  	reset20 = {"number", 1}, -- 重置扭蛋机
e51ff6d2   zhouhaihai   冒险~
101
  }
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
102
  
e51ff6d2   zhouhaihai   冒险~
103
104
  function Activity:data()
  	return {
be4e8031   zhouhaihai   活动 拾荒
105
  		actime = self:getProperty("actime"),
7f9f002d   liuzujun   循环周活动
106
  		round = self:getProperty("round"),
7f9f002d   liuzujun   循环周活动
107
  		act4 = self:getProperty("act4"),
7f9f002d   liuzujun   循环周活动
108
  		act6 = self:getProperty("act6"),
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
109
110
111
112
113
  		act8 = self:getProperty("act8"),
  		act11 = self:getProperty("act11"),
  		act12 = self:getProperty("act12"),
  		act13 = self:getProperty("act13"),
  		act14 = self:getProperty("act14"),
1be743f3   liuzujun   扭蛋机调试
114
115
116
117
118
  
  		act17 = self:getProperty("act17"),
  		act18 = self:getProperty("act18"),
  		act19 = self:getProperty("act19"),
  		act20 = self:getProperty("act20"),
ac885527   liuzujun   联动签到活动
119
  		act24 = self:getProperty("act24"),
558c9044   zhouhaihai   物资危机
120
  		act26 = self:getProperty("act26"),
ac885527   liuzujun   联动签到活动
121
122
  
  		act28 = self:getProperty("act28"),
cab7184b   chenyueqi   活动能量bug
123
  		act30 = self:getProperty("act30"),
c756d4df   liuzujun   新年将军令活动
124
  
98be031a   liuzujun   新年活动
125
126
  		act33 = self:getProperty("act33"),
  
c756d4df   liuzujun   新年将军令活动
127
  		act34 = self:getProperty("act34"),
336fa4a6   chenyueqi   新的活动签到,新春三重奏之返还0消耗
128
  		act36 = self:getProperty("act36"),
0769908c   zhangqijia   feat: 常规世界boss
129
  		act42 = self:getProperty("act42"),
386cd4c1   zhangqijia   feat: 狩猎祭,增加重置扭蛋机协议
130
131
  
  		reset20 = self:getProperty("reset20")
e51ff6d2   zhouhaihai   冒险~
132
  	}
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
133
134
  end
  
e51ff6d2   zhouhaihai   冒险~
135
  
9a1c54b2   zhouhaihai   活动
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
  function Activity:updateProperty(params)
  	local type, default = table.unpack(self.schema[params.field])
  
  	if params.delta then
  		self:incrProperty(params.field, params.delta)
  		if not params.notNotify then
  			self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
  		end
  		return true
  	end
  	if params.value then
  		self:setProperty(params.field, params.value)
  		if not params.notNotify then
  			self.owner:notifyUpdateProperty(params.field, self:getProperty(params.field))
  		end
  		return true
  	end
  	return false
  end
  
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
156
157
158
  function Activity:isOpenRaw(activityId, now)
  	activityId = checkActivityType(activityId)
  	local actData = csvdb["activity_ctrlCsv"][activityId]
ea40710f   zhouhaihai   活动
159
160
161
162
163
164
165
166
  	if not actData then return end
  
  	if actData.time == "" then -- 关闭
  		return false
  	end
  
  	local st = 0
  	local et = 0
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
167
  	--local now = skynet.timex()
ea40710f   zhouhaihai   活动
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
  
  	if actData.ttype == 0 then -- 时间开放
  		local openTimes = actData.time:toArray(false, "=")
  		if openTimes[1] ~= "0" then
  			st = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME))
  		end
  		if openTimes[2] ~= "0" then
  			et = toUnixtime(openTimes[2]..string_format("%02x", RESET_TIME))
  		end
   	elseif actData.ttype == 1 then -- 周期开放
   		local openTimes = actData.time:toArray(true, "=")
   		local resetTime = toUnixtime(tostring(openTimes[1]) .. string_format("%02x", RESET_TIME))
   		local r = math.floor((now - resetTime) / (openTimes[3] * 86400))
   		st = resetTime + r * (openTimes[3] * 86400)
   		et = st + openTimes[2] * 86400
  	else
  		return
  	end
  
  	if now >= st and (et == 0 or now < et) then
  		return true, st
  	end
  	return false
  end
  
  -- 缓存开放
9a1c54b2   zhouhaihai   活动
194
195
  function Activity:isOpen(activityType)
  	activityType = checkActivityType(activityType)
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
196
197
198
199
200
201
202
203
204
205
206
  	--return self._isOpen[activityType]
  	local open = false
  	for id, data in pairs(csvdb["activity_ctrlCsv"]) do
  		if data.showType == activityType then
  			open = self._isOpen[data.id]
  			if open then
  				return true, data.id
  			end
  		end
  	end
  	return false
ea40710f   zhouhaihai   活动
207
208
  end
  
686d4fd6   liuzujun   兑换活动支持兑换多个, 新增卡池
209
210
211
212
  function Activity:isOpenById(id, activityType)
  	activityType = checkActivityType(activityType)
  	local cfg = csvdb["activity_ctrlCsv"][id]
  	if not cfg then return false end
be697585   liuzujun   活动剧情解锁
213
  	if activityType ~= 0 and cfg.showType ~= activityType then return false end
686d4fd6   liuzujun   兑换活动支持兑换多个, 新增卡池
214
  
b8b1c164   liuzujun   扭蛋活动,万能碎片bug
215
216
217
  	return self._isOpen[id]
  end
  
386cd4c1   zhangqijia   feat: 狩猎祭,增加重置扭蛋机协议
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
  function Activity:isResetById(id, activityType)
  	activityType = checkActivityType(activityType)
  	local cfg = csvdb["activity_ctrlCsv"][id]
  	if not cfg then return false end
  	if activityType ~= 0 and cfg.showType ~= activityType then return false end
  	return self:getResetData(activityType) == 0
  end
  
  function Activity:getResetData(actType)
  	actType = checkActivityType(actType)
  	return self:getProperty("reset" .. actType)
  end
  
  function Activity:updateResetData(actType, reset)
  	actType = checkActivityType(actType)
  	self:updateProperty({field = "reset" .. actType, value = reset})
  end
  
ea40710f   zhouhaihai   活动
236
237
238
239
  function Activity:getActData(actType)
  	actType = checkActivityType(actType)
  	return self:getProperty("act" .. actType)
  end
9a1c54b2   zhouhaihai   活动
240
  
ea40710f   zhouhaihai   活动
241
242
243
  function Activity:updateActData(actType, data, notNotify)
  	actType = checkActivityType(actType)
  	self:updateProperty({field = "act" .. actType,  value = data, notNotify = notNotify})
9a1c54b2   zhouhaihai   活动
244
245
  end
  
ea40710f   zhouhaihai   活动
246
  
9a1c54b2   zhouhaihai   活动
247
  -- 跨天刷新 --登录刷新
ea40710f   zhouhaihai   活动
248
249
  function Activity:checkActivityStatus(now, isCrossDay, notify)
  	self._isOpen = {}
be4e8031   zhouhaihai   活动 拾荒
250
  	local actime = self:getProperty("actime")
ea40710f   zhouhaihai   活动
251
  	local change = false
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
252
253
254
  	for actId, actData in pairs(csvdb["activity_ctrlCsv"]) do
  		local isOpen, startTime = self:isOpenRaw(actId, now)
  		self._isOpen[actId] = isOpen
ea40710f   zhouhaihai   活动
255
256
  
  		if isOpen then
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
257
  			if actime[actId] and actime[actId] == startTime then -- 还是之前的状态 开放中
66fe093a   liuzujun   元旦关卡活动
258
  				self:onLoginActivity(actId)
ea40710f   zhouhaihai   活动
259
  			else  -- 重置
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
260
261
262
  				actime[actId] = startTime
  				self:closeActivity(actId, notify, true)
  				self:initActivity(actId, isCrossDay, notify)
ea40710f   zhouhaihai   活动
263
264
265
  				change = true
  			end
  		else
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
266
267
268
  			if actime[actId] then
  				self:closeActivity(actId, notify)
  				actime[actId] = nil
ea40710f   zhouhaihai   活动
269
270
271
272
273
  				change = true
  			end
  		end
  	end
  	if change then
be4e8031   zhouhaihai   活动 拾荒
274
  		self:updateProperty({field = "actime", value = actime, notNotify = not notify})
ea40710f   zhouhaihai   活动
275
  	end
9a1c54b2   zhouhaihai   活动
276
277
  end
  
ea40710f   zhouhaihai   活动
278
  local activityFunc = {}
9a1c54b2   zhouhaihai   活动
279
  
ea40710f   zhouhaihai   活动
280
281
282
283
284
285
286
287
288
289
290
291
292
  activityFunc[Activity.ActivityType.Sign] = {
  	-- ["check"] = function(self, actType, notify) -- 检查
  	-- end,
  	["init"] = function(self, actType, isCrossDay, notify)
  		if not isCrossDay then
  			activityFunc[Activity.ActivityType.Sign]["crossDay"](self, actType, notify)
  		end
  	end,
  	-- ["close"] = function(self, actType, notify)
  	-- end,
  	["crossDay"] = function(self, actType, notify)
  		local curData = self:getActData(actType)
  		curData[0] = (curData[0] or 0) + 1
be4e8031   zhouhaihai   活动 拾荒
293
  		local actData = csvdb["new_signInCsv"]
ea40710f   zhouhaihai   活动
294
295
296
297
298
299
  		if curData[0] > #actData then return end -- 满了就忽略了
  
  		-- 没满更新一下
  		self:updateActData(actType, curData, not notify)
  	end,
  }
9a1c54b2   zhouhaihai   活动
300
  
7f9f002d   liuzujun   循环周活动
301
302
303
304
  --loop1:累计料理贩卖N次
  --loop2:累计招募N次
  --loop3:累计资助N次
  --loop4:时钟箱拆解N个
93f6e69b   liuzujun   拾荒选择时间,抽卡增加sr保底
305
  function Activity:checkWeeklyAct(actType, notify, count, pool)
7f9f002d   liuzujun   循环周活动
306
307
308
309
310
311
  		local actInfoMap = {
  			[Activity.ActivityType.DrawHero] = {mailId = MailId.ActDrawCardReward, table = "activity_loop2Csv"},
  			[Activity.ActivityType.AdvDraw] = {mailId = MailId.ActAdvDrawReward, table = "activity_loop3Csv"},
  			[Activity.ActivityType.OpenBox] = {mailId = MailId.ActOpenBoxReward, table = "activity_loop4Csv"},
  			[Activity.ActivityType.FoodSell] = {mailId = MailId.ActSellFoodReward, table = "activity_loop1Csv"}
  		}
93f6e69b   liuzujun   拾荒选择时间,抽卡增加sr保底
312
313
314
  		if actType == Activity.ActivityType.DrawHero and pool == DrawCardType.FriendDraw then
  			return
  		end
7f9f002d   liuzujun   循环周活动
315
316
317
  		local info = actInfoMap[actType]
  		if not info then return end
  
ee021c58   liuzujun   每周循环任务bug
318
319
320
321
322
  		local open, actId = self:isOpen(actType)
  		if not open then
  			return
  		end
  
7f9f002d   liuzujun   循环周活动
323
324
325
  		local curData = self:getActData(actType)
  		local roundData = self:getProperty("round")
  		local curRound = roundData[actType] or 0
ee021c58   liuzujun   每周循环任务bug
326
  		local ctrlData = csvdb["activity_ctrlCsv"][actId]
7f9f002d   liuzujun   循环周活动
327
328
329
330
331
332
333
334
  		if not ctrlData then return end
  		if curRound >= ctrlData.condition then
  			return
  		end
  		curData[0] = (curData[0] or 0) + count
  		local totalCnt = 0
  		local finishCnt = 0
  		local maxCondition = 0
b8d77233   liuzujun   拆解周活动跨轮数据异常bug
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
  		local flag = true
  		while flag do
  			--print("tatal number :", curData[0])
  			for i = 1, #csvdb[info.table] do
  				local cfg = csvdb[info.table][i]
  			--for k, cfg in pairs(csvdb[info.table] or {}) do
  				totalCnt = totalCnt + 1
  				if maxCondition < cfg.condition1 then
  					maxCondition = cfg.condition1
  				end
  				--print("cur condition", cfg.condition1)
  				if curData[0] < cfg.condition1 then
  					flag = false
  					break
  				end
c59e058b   zhouhaihai   新一批日志记录
350
  
b8d77233   liuzujun   拆解周活动跨轮数据异常bug
351
352
353
  				--print(curData[0], cfg.condition1)
  				if not curData[cfg.id] and curData[0] >= cfg.condition1 then
  					if info.mailId then 
c59e058b   zhouhaihai   新一批日志记录
354
  
b8d77233   liuzujun   拆解周活动跨轮数据异常bug
355
356
357
358
359
  						self.owner:log("activity", {
  							activity_id = cfg.id, -- 活动ID(或活动指定任务的ID)
  							activity_type = actType, -- 活动类型,见活动类型枚举表
  							activity_reward = cfg.reward:toNumMap(), -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  						})
c59e058b   zhouhaihai   新一批日志记录
360
  
b8d77233   liuzujun   拆解周活动跨轮数据异常bug
361
362
363
364
365
366
  						self.owner:sendMail(info.mailId, nil, cfg.reward, {cfg.condition1})
  						curData[cfg.id] = 1
  					end
  				end
  				if curData[cfg.id] then
  					finishCnt = finishCnt + 1
7f9f002d   liuzujun   循环周活动
367
368
  				end
  			end
b8d77233   liuzujun   拆解周活动跨轮数据异常bug
369
370
371
372
373
374
375
376
377
378
379
380
381
  			if totalCnt == finishCnt then
  				roundData[actType] = (roundData[actType] or 0) + 1
  				for k,v in pairs(curData) do
  					if k == 0 then
  						curData[k] = curData[0] >= maxCondition and curData[0] - maxCondition or 0
  					else
  						curData[k] = nil
  					end
  				end
  				--print("cur round ".. roundData[actType], ctrlData.condition)
  				if roundData[actType] >= ctrlData.condition then
  					curData[0] = maxCondition
  					flag = false
7f9f002d   liuzujun   循环周活动
382
  				end
b8d77233   liuzujun   拆解周活动跨轮数据异常bug
383
  				self:updateProperty({field = "round", value = roundData, notNotify = not notify})
7f9f002d   liuzujun   循环周活动
384
  			end
7f9f002d   liuzujun   循环周活动
385
386
387
388
389
390
  		end
  		self:updateActData(actType, curData, not notify)
  end
  
  -- 抽卡周
  activityFunc[Activity.ActivityType.DrawHero] = {
93f6e69b   liuzujun   拾荒选择时间,抽卡增加sr保底
391
392
  	["check"] = function(self, actType, notify, count, pool) -- 检查
  		self:checkWeeklyAct(actType, notify, count, pool)
7f9f002d   liuzujun   循环周活动
393
394
395
396
397
398
399
400
401
  	end,
  	["init"] = function(self, actType, isCrossDay, notify)
  		local roundData = self:getProperty("round")
  		roundData[actType] = 0
  		self:updateProperty({field = "round",  value = roundData, notNotify = not notify})
  	end,
  	-- ["close"] = function(self, actType, notify)
  	-- end,
  	["crossDay"] = function(self, actType, notify)
7f9f002d   liuzujun   循环周活动
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
  		self.owner:sendMail(MailId.ActDrawCard)
  	end,
  }
  
  -- 售卖周
  activityFunc[Activity.ActivityType.FoodSell] = {
  	["check"] = function(self, actType, notify, count) -- 检查
  		self:checkWeeklyAct(actType, notify, count)
  	end,
  	["init"] = function(self, actType, isCrossDay, notify)
  		local roundData = self:getProperty("round")
  		roundData[actType] = 0
  		self:updateProperty({field = "round",  value = roundData, notNotify = not notify})
  	end,
  	-- ["close"] = function(self, actType, notify)
  	-- end,
  	["crossDay"] = function(self, actType, notify)
7f9f002d   liuzujun   循环周活动
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
  		self.owner:sendMail(MailId.ActSellFood)
  	end,
  }
  
  -- 拾荒周
  activityFunc[Activity.ActivityType.AdvDraw] = {
  	["check"] = function(self, actType, notify, count) -- 检查
  		self:checkWeeklyAct(actType, notify, count)
  	end,
  	["init"] = function(self, actType, isCrossDay, notify)
  		local roundData = self:getProperty("round")
  		roundData[actType] = 0
  		self:updateProperty({field = "round",  value = roundData, notNotify = not notify})
  	end,
  	-- ["close"] = function(self, actType, notify)
  	-- end,
  	["crossDay"] = function(self, actType, notify)
7f9f002d   liuzujun   循环周活动
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
  		self.owner:sendMail(MailId.ActAdvDraw)
  	end,
  }
  
  -- 拆解周
  activityFunc[Activity.ActivityType.OpenBox] = {
  	["check"] = function(self, actType, notify, count) -- 检查
  		self:checkWeeklyAct(actType, notify, count)
  	end,
  	["init"] = function(self, actType, isCrossDay, notify)
  		local roundData = self:getProperty("round")
  		roundData[actType] = 0
  		self:updateProperty({field = "round",  value = roundData, notNotify = not notify})
  	end,
  	-- ["close"] = function(self, actType, notify)
  	-- end,
  	["crossDay"] = function(self, actType, notify)
7f9f002d   liuzujun   循环周活动
453
454
455
456
  		self.owner:sendMail(MailId.ActOpenBox)
  	end,
  }
  
51d9d20b   liuzujun   付费签到,应用市场反馈
457
458
459
460
461
  -- 付费签到
  activityFunc[Activity.ActivityType.PaySignIn] = {
  	["init"] = function(self, actType, isCrossDay, notify)
  		self:updateActData(actType, {}, not notify)
  	end,
ede282c0   liuzujun   付费签到规则改为按登录天数计算进度...
462
463
464
465
466
  	["crossDay"] = function(self, actType, notify)
  		local curData = self:getActData(actType)
  		curData[0] = (curData[0] or 0) + 1
  		self:updateActData(actType, curData, not notify)
  	end,
460afa6e   liuzujun   付费签到改为主动领取,战斗关卡不一...
467
468
  	["close"] = function(self, actType, notify)
  		self.owner.storeData:SetActGoodsFlag("paySignIn", 0)
d4d00016   liuzujun   付费签到开始时间改为开服时间
469
470
471
472
473
474
475
476
477
  		
  		local rechargeRecord = self.owner.storeData:getProperty("payR")
  		for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do
  			if cfg.shop == 2 and cfg.type == CardType.PaySignCard then
  				rechargeRecord[id] = nil
  				break
  			end
  		end
  		self.owner.storeData:updateProperty({field="payR", value=rechargeRecord})
460afa6e   liuzujun   付费签到改为主动领取,战斗关卡不一...
478
  	end,
51d9d20b   liuzujun   付费签到,应用市场反馈
479
480
  }
  
e52c384f   liuzujun   探索指令bug, 充值返利活动
481
482
483
484
485
  -- 充值反馈
  activityFunc[Activity.ActivityType.PayBack] = {
  	["check"] = function(self, actType, notify, twd) -- 检查
  		local oldVal = self:getActData(actType) or 0
  		local newVal = oldVal + twd
4709685d   liuzujun   返利邮件拼接充值档位
486
  		local gift, checkPoint = self.owner:getPaybackReward(oldVal, newVal)
e52c384f   liuzujun   探索指令bug, 充值返利活动
487
  		if gift ~= "" then
1cfe4c75   liuzujun   充值返利邮件内容优化
488
  			local strCp = table.concat(checkPoint ,"、")
4709685d   liuzujun   返利邮件拼接充值档位
489
  			self.owner:sendMail(MailId.PayBackAward, nil, gift, {newVal, strCp})
e52c384f   liuzujun   探索指令bug, 充值返利活动
490
491
492
493
494
495
496
497
498
499
  		end
  		self:updateActData(actType, newVal, not notify)
  	end,
  	["init"] = function(self, actType, isCrossDay, notify)
  		self:updateActData(actType, {}, not notify)
  	end,
  	-- ["close"] = function(self, actType, notify)
  	-- end,
  }
  
190e1415   liuzujun   英雄帖活动初始化
500
501
502
  -- 英雄帖
  activityFunc[Activity.ActivityType.CalendaTask] = {
  	["init"] = function(self, actType, isCrossDay, notify)
dfa9ae5e   liuzujun   战令任务活动
503
  		local calTask = self.owner:getProperty("calTask")
190e1415   liuzujun   英雄帖活动初始化
504
  		calTask = {}
86a873b9   liuzujun   活动任务数据重置
505
  		self.owner:updateProperty({field="calTask", value=calTask})
190e1415   liuzujun   英雄帖活动初始化
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
  		local role = self.owner
  		local buildL = role.dinerData:getProperty("buildL")
  		local curLevel = buildL:getv(1, 1)
  		role:checkTaskEnter("DinerLevelUp", {level = curLevel})
  
  		role:checkTaskEnter("HeroLvlCollect", {})
  		role:checkTaskEnter("HeroQualityCollect", {})
  
  		local curPopular = role.dinerData:getProperty("popular")
  		role:checkTaskEnter("DinerPopular", {count = curPopular})
  
  		local rLevel = role:getProperty("level")
  		role:checkTaskEnter("RoleLevelUp", {level = rLevel})
  
  		local towerInfo = role:getProperty("towerInfo")
03c619fb   chenyueqi   电波塔属性塔功能部分功能草稿
521
  		role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1})
190e1415   liuzujun   英雄帖活动初始化
522
  		--"PvpWin"
576c791c   liuzujun   玛尼英雄帖活动通过任务bug 元旦...
523
524
  		--role:checkTaskEnter("HangPass", {id = 0})
  		role:checkCalendaTask(true, 15, 3)
190e1415   liuzujun   英雄帖活动初始化
525
  		role:checkTaskEnter("HeroStarCollect", {})
9e5f9701   zhangqijia   feat: 玛尼的英雄帖增加任务类型
526
  		role:checkTaskEnter("HeroStartSum", {})
190e1415   liuzujun   英雄帖活动初始化
527
528
529
  		role:checkTaskEnter("RuneQualityCollect", {})
  
  	end,
b620581a   liuzujun   战令活动,战令相关的任务活动
530
  	["crossDay"] = function(self, actType, notify, actId)
dfa9ae5e   liuzujun   战令任务活动
531
  		local actData = self.owner:getProperty("calTask") or {}
b620581a   liuzujun   战令活动,战令相关的任务活动
532
533
534
535
536
  		local record = actData["r"] or {}
  		local actCfg = csvdb["activity_taskCsv"][actId]
  		if not actCfg then return end
  		local change = false
  		for taskId, cfg in pairs(actCfg) do
dfa9ae5e   liuzujun   战令任务活动
537
  			if cfg["resetType"] == 1 then 	-- 每日重置
b620581a   liuzujun   战令活动,战令相关的任务活动
538
539
540
541
542
543
  				record[taskId] = nil
  				actData[taskId] = nil
  				change = true
  			end
  		end
  		if change then
dfa9ae5e   liuzujun   战令任务活动
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
  			self.owner:updateProperty({field="calTask", value=actData})
  		end
  	end,
  	["crossWeek"] = function(self, actType, notify, actId)
  		local actData = self.owner:getProperty("calTask") or {}
  		local record = actData["r"] or {}
  		local actCfg = csvdb["activity_taskCsv"][actId]
  		if not actCfg then return end
  		local change = false
  		for taskId, cfg in pairs(actCfg) do
  			if cfg["resetType"] == 2 then 	-- 每周重置
  				record[taskId] = nil
  				actData[taskId] = nil
  				change = true
  			end
  		end
  		if change then
  			self.owner:updateProperty({field="calTask", value=actData})
b620581a   liuzujun   战令活动,战令相关的任务活动
562
563
  		end
  	end,
f76d63e1   liuzujun   联动任务活动
564
  	["close"] = function(self, actType, notify)
dfa9ae5e   liuzujun   战令任务活动
565
  		self.owner:updateProperty({field="calTask", value={}})
f76d63e1   liuzujun   联动任务活动
566
  	end,
190e1415   liuzujun   英雄帖活动初始化
567
568
  }
  
b620581a   liuzujun   战令活动,战令相关的任务活动
569
  -- 活动任务 仅供春节活动使用 防冲突
dfa9ae5e   liuzujun   战令任务活动
570
  activityFunc[Activity.ActivityType.BattleCommandTask] = {
b620581a   liuzujun   战令活动,战令相关的任务活动
571
  	["init"] = function(self, actType, isCrossDay, notify)
dfa9ae5e   liuzujun   战令任务活动
572
573
  		local bcTask = self.owner:getProperty("bcTask")
  		bcTask = {}
86a873b9   liuzujun   活动任务数据重置
574
  		self.owner:updateProperty({field="bcTask", value=bcTask})
b620581a   liuzujun   战令活动,战令相关的任务活动
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
  		local role = self.owner
  		local buildL = role.dinerData:getProperty("buildL")
  		local curLevel = buildL:getv(1, 1)
  		role:checkTaskEnter("DinerLevelUp", {level = curLevel})
  
  		role:checkTaskEnter("HeroLvlCollect", {})
  		role:checkTaskEnter("HeroQualityCollect", {})
  
  		local curPopular = role.dinerData:getProperty("popular")
  		role:checkTaskEnter("DinerPopular", {count = curPopular})
  
  		local rLevel = role:getProperty("level")
  		role:checkTaskEnter("RoleLevelUp", {level = rLevel})
  
  		local towerInfo = role:getProperty("towerInfo")
03c619fb   chenyueqi   电波塔属性塔功能部分功能草稿
590
  		role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1})
b620581a   liuzujun   战令活动,战令相关的任务活动
591
592
593
594
  		--"PvpWin"
  		--role:checkTaskEnter("HangPass", {id = 0})
  		role:checkCalendaTask(true, 15, 3)
  		role:checkTaskEnter("HeroStarCollect", {})
9e5f9701   zhangqijia   feat: 玛尼的英雄帖增加任务类型
595
  		role:checkTaskEnter("HeroStartSum", {})
b620581a   liuzujun   战令活动,战令相关的任务活动
596
597
598
599
  		role:checkTaskEnter("RuneQualityCollect", {})
  
  	end,
  	["crossDay"] = function(self, actType, notify, actId)
dfa9ae5e   liuzujun   战令任务活动
600
  		local actData = self.owner:getProperty("bcTask") or {}
b620581a   liuzujun   战令活动,战令相关的任务活动
601
602
603
604
605
606
607
608
609
610
611
612
  		local record = actData["r"] or {}
  		local actCfg = csvdb["activity_taskCsv"][actId]
  		if not actCfg then return end
  		local change = false
  		for taskId, cfg in pairs(actCfg) do
  			if cfg["resetType"] == 1 then 	-- 每日充值
  				record[taskId] = nil
  				actData[taskId] = nil
  				change = true
  			end
  		end
  		if change then
dfa9ae5e   liuzujun   战令任务活动
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
  			self.owner:updateProperty({field="bcTask", value=actData})
  		end
  	end,
  	["crossWeek"] = function(self, actType, notify, actId)
  		local actData = self.owner:getProperty("bcTask") or {}
  		local record = actData["r"] or {}
  		local actCfg = csvdb["activity_taskCsv"][actId]
  		if not actCfg then return end
  		local change = false
  		for taskId, cfg in pairs(actCfg) do
  			if cfg["resetType"] == 2 then 	-- 每周重置
  				record[taskId] = nil
  				actData[taskId] = nil
  				change = true
  			end
  		end
  		if change then
  			self.owner:updateProperty({field="bcTask", value=actData})
b620581a   liuzujun   战令活动,战令相关的任务活动
631
632
633
  		end
  	end,
  	["close"] = function(self, actType, notify)
dfa9ae5e   liuzujun   战令任务活动
634
  		self.owner:updateProperty({field="bcTask", value={}})
b620581a   liuzujun   战令活动,战令相关的任务活动
635
636
637
  	end,
  }
  
847f9a7b   liuzujun   兑换活动,邮件内容修改
638
639
640
  -- 兑换
  activityFunc[Activity.ActivityType.Exchange] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
847f9a7b   liuzujun   兑换活动,邮件内容修改
641
642
643
644
  		local actData = self:getActData(actType) or {}
  		actData[actId] = {}
  		self:updateActData(actType, actData, not notify)
  	end,
a6898231   liuzujun   兑换活动上线检测是否需要刷新
645
  	["login"] = function(self, actType, actId)
7245bc4b   liuzujun   登入刷新兑换活动商店
646
  		activityFunc[Activity.ActivityType.Exchange]["crossDay"](self, actType, true, actId)
a6898231   liuzujun   兑换活动上线检测是否需要刷新
647
  	end,
2bc706ab   liuzujun   兑换活动重置,累充功能
648
649
650
651
652
653
654
655
  	["crossDay"] = function(self, actType, notify, actId)
  		local actData = self:getActData(actType) or {}
  		local lastTs = actData["ts"] or 0
  		local timeNow = skynet.timex()
  		local cfg = csvdb["activity_ctrlCsv"][actId]
  		if not cfg then return end
  		local refreshTimes = cfg.condition2:toArray(false, "=")
  		for i = 1, #refreshTimes do
16f58f21   liuzujun   兑换商店不刷新bug
656
  			local rt = toUnixtime(refreshTimes[i]..string_format("%02x", RESET_TIME))
2bc706ab   liuzujun   兑换活动重置,累充功能
657
658
659
660
661
  			if timeNow >= rt and rt > lastTs then
  				lastTs = rt
  				actData = {}
  			end
  		end
16f58f21   liuzujun   兑换商店不刷新bug
662
663
  		if not next(actData) then
  			actData["ts"] = timeNow
2bc706ab   liuzujun   兑换活动重置,累充功能
664
  			self:updateActData(actType, actData, not notify)
78e5b90e   liuzujun   完成需求:新玩家任务
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
  		end
  	end,
  	["close"] = function(self, actType, notify, actId)
  		local actData = self:getActData(actType) or {}
  		actData[actId] = nil
  		self:updateActData(actType, actData, not notify)
  	end,
  }
  
  -- 新用户活动任务 
  activityFunc[Activity.ActivityType.NewUserTask] = {
  	["init"] = function(self, actType, isCrossDay, notify)
  		local nbTask = self.owner:getProperty("nbTask")
  		nbTask = {}
  		self.owner:updateProperty({field="nbTask", value=nbTask})
  		local role = self.owner
  		local buildL = role.dinerData:getProperty("buildL")
  		local curLevel = buildL:getv(1, 1)
  		role:checkTaskEnter("DinerLevelUp", {level = curLevel})
  
  		role:checkTaskEnter("HeroLvlCollect", {})
  		role:checkTaskEnter("HeroQualityCollect", {})
  
  		local curPopular = role.dinerData:getProperty("popular")
  		role:checkTaskEnter("DinerPopular", {count = curPopular})
  
  		local rLevel = role:getProperty("level")
  		role:checkTaskEnter("RoleLevelUp", {level = rLevel})
  
  		local towerInfo = role:getProperty("towerInfo")
  		role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1})
  		--"PvpWin"
  		--role:checkTaskEnter("HangPass", {id = 0})
  		role:checkCalendaTask(true, 15, 3)
  		role:checkTaskEnter("HeroStarCollect", {})
9e5f9701   zhangqijia   feat: 玛尼的英雄帖增加任务类型
700
  		role:checkTaskEnter("HeroStartSum", {})
78e5b90e   liuzujun   完成需求:新玩家任务
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
  		role:checkTaskEnter("RuneQualityCollect", {})
  
  	end,
  	["crossDay"] = function(self, actType, notify, actId)
  		local actData = self.owner:getProperty("nbTask") or {}
  		local record = actData["r"] or {}
  		local actCfg = csvdb["activity_taskCsv"][actId]
  		if not actCfg then return end
  		local change = false
  		for taskId, cfg in pairs(actCfg) do
  			if cfg["resetType"] == 1 then 	-- 每日重置
  				record[taskId] = nil
  				actData[taskId] = nil
  				change = true
  			end
  		end
  		if change then
  			self.owner:updateProperty({field="nbTask", value=actData})
  		end
  	end,
  	["crossWeek"] = function(self, actType, notify, actId)
  		local actData = self.owner:getProperty("nbTask") or {}
  		local record = actData["r"] or {}
  		local actCfg = csvdb["activity_taskCsv"][actId]
  		if not actCfg then return end
  		local change = false
  		for taskId, cfg in pairs(actCfg) do
  			if cfg["resetType"] == 2 then 	-- 每周重置
  				record[taskId] = nil
  				actData[taskId] = nil
  				change = true
  			end
  		end
  		if change then
  			self.owner:updateProperty({field="nbTask", value=actData})
  		end
  	end,
  	["close"] = function(self, actType, notify)
  		self.owner:updateProperty({field="nbTask", value={}})
  	end,
  }
  
  -- 兑换
  activityFunc[Activity.ActivityType.Exchange] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
  		local actData = self:getActData(actType) or {}
  		actData[actId] = {}
  		self:updateActData(actType, actData, not notify)
  	end,
  	["login"] = function(self, actType, actId)
  		activityFunc[Activity.ActivityType.Exchange]["crossDay"](self, actType, true, actId)
  	end,
  	["crossDay"] = function(self, actType, notify, actId)
  		local actData = self:getActData(actType) or {}
  		local lastTs = actData["ts"] or 0
  		local timeNow = skynet.timex()
  		local cfg = csvdb["activity_ctrlCsv"][actId]
  		if not cfg then return end
  		local refreshTimes = cfg.condition2:toArray(false, "=")
  		for i = 1, #refreshTimes do
  			local rt = toUnixtime(refreshTimes[i]..string_format("%02x", RESET_TIME))
  			if timeNow >= rt and rt > lastTs then
  				lastTs = rt
  				actData = {}
  			end
  		end
  		if not next(actData) then
  			actData["ts"] = timeNow
  			self:updateActData(actType, actData, not notify)
2bc706ab   liuzujun   兑换活动重置,累充功能
770
771
772
773
774
775
776
  		end
  	end,
  	["close"] = function(self, actType, notify, actId)
  		local actData = self:getActData(actType) or {}
  		actData[actId] = nil
  		self:updateActData(actType, actData, not notify)
  	end,
847f9a7b   liuzujun   兑换活动,邮件内容修改
777
778
779
780
781
782
783
784
  }
  
  -- 扭蛋机
  activityFunc[Activity.ActivityType.Gachakon] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
  		self:updateActData(actType, {}, not notify)
  	end,
  	["crossDay"] = function(self, actType, notify)
386cd4c1   zhangqijia   feat: 狩猎祭,增加重置扭蛋机协议
785
  		self:updateResetData(actType, 1)
2ce63aa5   zhangqijia   fix: 扭蛋机,跨天自动重置改为...
786
  		--self:updateActData(actType, {}, not notify)
847f9a7b   liuzujun   兑换活动,邮件内容修改
787
  	end,
386cd4c1   zhangqijia   feat: 狩猎祭,增加重置扭蛋机协议
788
789
790
791
792
  	["reset"] = function(self, actType)
  		if self:getResetData(actType) == 0 then return end
  		self:updateResetData(actType, 0)
  		self:updateActData(actType, {})
  	end
847f9a7b   liuzujun   兑换活动,邮件内容修改
793
794
  }
  
eb5ffd1c   liuzujun   世界boss翻牌奖励 活动卡池保底...
795
796
797
798
799
800
801
802
  -- 活动卡池
  activityFunc[Activity.ActivityType.ActHeroPool] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
  	end,
  	["close"] = function(self, actType, notify, actId)
  		local actData = self:getActData(actType)
  		local cfg = csvdb["activity_ctrlCsv"][actId]
  		if not cfg then return end
0c54995a   liuzujun   第一次通关拾荒章节推送限时礼包,活...
803
  		-- 保底次数转换成万能碎片
0285ef6c   liuzujun   活动卡池结束回馈次数通关邮件折算碎...
804
805
806
807
808
  		--local count = math.ceil(((actData[cfg.condition] or 0) / 100) * 60)
  		--if count > 0 then
  		--	local gift = {[723] = count}
  		--	self.owner:sendMail(MailId.ActivityPoolRet, nil, gift, {})
  		--end
eb5ffd1c   liuzujun   世界boss翻牌奖励 活动卡池保底...
809
810
811
812
813
  		actData[cfg.condition] = nil
  		self:updateActData(actType, actData, not notify)
  	end,
  }
  
2bc706ab   liuzujun   兑换活动重置,累充功能
814
815
816
817
  -- 挂机掉落
  activityFunc[Activity.ActivityType.HangDrop] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
  		local actime = self:getProperty("actime")
576c791c   liuzujun   玛尼英雄帖活动通过任务bug 元旦...
818
819
  		local ctime = self.owner:getProperty("ctime")
  		local startTime = math.max(actime[actId], ctime)
2bc706ab   liuzujun   兑换活动重置,累充功能
820
821
822
823
824
825
826
827
  		local actData = self:getActData(actType) or 0
  		local cfg = csvdb["activity_putCsv"][actId]
  		if not cfg then return end
  		actData = startTime
  		self:updateActData(actType, actData, not notify)
  	end
  }
  
66fe093a   liuzujun   元旦关卡活动
828
829
830
831
832
833
834
  --ChallengeLevel
  activityFunc[Activity.ActivityType.ChallengeLevel] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
  		self:getBattleTicket(actId)
  	end,
  	["login"] = function(self, actType, actId)
  		self:getBattleTicket(actId)
50da0e37   liuzujun   挑战关卡活动 普通关卡扫荡,购买挑战次数
835
836
837
838
839
840
  	end,
  	["crossDay"] = function(self, actType, notify)
  		local actData = self:getActData(actType)
  		actData["buyC"] = 0
  		self:updateActData(actType, actData, not notify)
  	end,
66fe093a   liuzujun   元旦关卡活动
841
842
  }
  
0769908c   zhangqijia   feat: 常规世界boss
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
  --RegularWorldBoos
  activityFunc[Activity.ActivityType.RegularWorldBoos] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
  		self:getRegularWorldBossTicket(actId)
  	end,
  	["login"] = function(self, actType, actId)
  		self:getRegularWorldBossTicket(actId)
  	end,
  	["crossDay"] = function(self, actType, notify)
  		local actData = self:getActData(actType)
  		actData["buyC"] = 0
  		self:updateActData(actType, actData, not notify)
  	end,
  }
  
66fe093a   liuzujun   元旦关卡活动
858
859
860
861
862
863
864
865
866
  function Activity:onLoginActivity(actId)
  	local actData = csvdb["activity_ctrlCsv"][actId]
  	if not actData then return end
  	local actType = actData.showType
  	if activityFunc[actType] and activityFunc[actType]['login'] then
  		activityFunc[actType]["login"](self, actType, actId)
  	end
  end
  
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
867
868
869
870
  function Activity:initActivity(actId, isCrossDay, notify)
  	local actData = csvdb["activity_ctrlCsv"][actId]
  	if not actData then return end
  	local actType = actData.showType
66fe093a   liuzujun   元旦关卡活动
871
  	if activityFunc[actType] and activityFunc[actType]['init'] then
847f9a7b   liuzujun   兑换活动,邮件内容修改
872
  		activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId)
ea40710f   zhouhaihai   活动
873
874
875
  	end
  end
  
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
876
877
878
879
  function Activity:closeActivity(actId, notify, notUpdateAct)
  	local actData = csvdb["activity_ctrlCsv"][actId]
  	if not actData then return end
  	local actType = actData.showType
ea40710f   zhouhaihai   活动
880
  	if activityFunc[actType] and activityFunc[actType]['close'] then
847f9a7b   liuzujun   兑换活动,邮件内容修改
881
  		activityFunc[actType]["close"](self, actType, notify, actId)
ea40710f   zhouhaihai   活动
882
  	end
fb344e8a   liuzujun   活动结束回收邮件
883
  	self:recycleActItem(actId)
7f9f002d   liuzujun   循环周活动
884
  	if Activity.schema["act".. actType] then
eb5ffd1c   liuzujun   世界boss翻牌奖励 活动卡池保底...
885
886
887
  		if not Activity.schema["act" .. actType][3] then 
  			self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct)
  		end
7f9f002d   liuzujun   循环周活动
888
  	end
ea40710f   zhouhaihai   活动
889
890
891
  end
  
  function Activity:refreshDailyData(notify)
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
892
893
894
895
  	for actId, status in pairs(self._isOpen) do
  		local actData = csvdb["activity_ctrlCsv"][actId]
  		if status and actData then
  			local actType = actData.showType
ea40710f   zhouhaihai   活动
896
  			if activityFunc[actType] and activityFunc[actType]['crossDay'] then
2bc706ab   liuzujun   兑换活动重置,累充功能
897
  				activityFunc[actType]["crossDay"](self, actType, notify, actId)
ea40710f   zhouhaihai   活动
898
899
900
  			end
  		end
  	end
9a1c54b2   zhouhaihai   活动
901
902
  end
  
dfa9ae5e   liuzujun   战令任务活动
903
904
905
906
907
908
909
910
911
912
913
914
  function Activity:refreshWeekData(notify)
  	for actId, status in pairs(self._isOpen) do
  		local actData = csvdb["activity_ctrlCsv"][actId]
  		if status and actData then
  			local actType = actData.showType
  			if activityFunc[actType] and activityFunc[actType]['crossWeek'] then
  				activityFunc[actType]["crossWeek"](self, actType, notify, actId)
  			end
  		end
  	end
  end
  
386cd4c1   zhangqijia   feat: 狩猎祭,增加重置扭蛋机协议
915
916
917
918
919
920
921
922
923
  function Activity:resetActDataById(actId)
  	local actData = csvdb["activity_ctrlCsv"][actId]
  	if not actData then return end
  	local actType = actData.showType
  	if activityFunc[actType] and activityFunc[actType]['reset'] then
  		activityFunc[actType]["reset"](self, actType)
  	end
  end
  
ea40710f   zhouhaihai   活动
924
  function Activity:checkActivity(notNotify, activityType, ...)
9a1c54b2   zhouhaihai   活动
925
  	if not activityType then return end
ea40710f   zhouhaihai   活动
926
927
928
  	if not self:isOpen(activityType) then return end
  	if activityFunc[activityType] and activityFunc[activityType]['check'] then
  		activityFunc[activityType]["check"](self, activityType, not notNotify, ...)
9a1c54b2   zhouhaihai   活动
929
930
931
  	end
  end
  
706b517e   liuzujun   翻倍掉落活动,商城免费宝箱
932
933
934
  -- 获取此次挂机掉落翻倍时长
  function Activity:getActHangDoubleTime(lastTs, nowTs)
  	local type = "DoubleDrop"
2bc706ab   liuzujun   兑换活动重置,累充功能
935
936
  	--local actId = checkActivityType(type)
  	local isOpen, actId = self:isOpen(type)
706b517e   liuzujun   翻倍掉落活动,商城免费宝箱
937
938
939
940
  	local openTs = self:getProperty("actime")[actId] or 0
  	local timeNow = skynet.timex()
  	lastTs =  math.max(lastTs, openTs)
  	if isOpen then
024370be   liuzujun   双倍掉掉落bug
941
  		if nowTs > openTs and nowTs > lastTs then
706b517e   liuzujun   翻倍掉落活动,商城免费宝箱
942
943
944
945
946
947
948
949
  			return nowTs - lastTs
  		else
  			return 0
  		end
  	end
  	return 0
  end
  
93f6e69b   liuzujun   拾荒选择时间,抽卡增加sr保底
950
951
  -- 获取活动卡池id
  function Activity:getActivityPool(mainType, subType)
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
952
953
954
  	local open, actId = self:isOpen(Activity.ActivityType.SsrUpPoolChange)
  	if not open then
  	--if not self:isOpen(Activity.ActivityType.SsrUpPoolChange) then	
93f6e69b   liuzujun   拾荒选择时间,抽卡增加sr保底
955
956
  		return 0
  	end
accf94c4   liuzujun   活动以类型标识,修改双倍活动bug
957
  	local actData = csvdb["activity_ctrlCsv"][actId]
93f6e69b   liuzujun   拾荒选择时间,抽卡增加sr保底
958
959
960
961
962
963
964
965
966
967
968
969
  	if not actData then return 0 end
  
  	local poolMap = actData.condition2:toMap(true, "=")
  	local key = mainType .. "_" .. subType
  	for k, v in pairs(poolMap) do
  		if k == key then
  			return v
  		end
  	end
  	return 0
  end
  
51d9d20b   liuzujun   付费签到,应用市场反馈
970
971
  -- 付费签到可领奖励
  function Activity:getPaySignReward()
7754304d   zhouhaihai   bug
972
  	local actGoodsFlag = self.owner.storeData:getProperty("actGoodsFlag")
51d9d20b   liuzujun   付费签到,应用市场反馈
973
974
975
976
977
978
979
980
  	local index = GetActGoodsIndex("paySignIn")
  	local flag = actGoodsFlag[index] or 0
  	if flag == 0 then return {} end
  
  	if not self.owner.activity:isOpen("PaySignIn") then return {} end
  
  	local diffDay = diffFromOpen() + 1
  
37bb4611   liuzujun   付费签到,抽卡阶段奖励,探索指令
981
  	local curData = self:getActData("PaySignIn")
51d9d20b   liuzujun   付费签到,应用市场反馈
982
  	local reward, change = {}
37bb4611   liuzujun   付费签到,抽卡阶段奖励,探索指令
983
  	for day, csvData in pairs(csvdb["pay_signInCsv"]) do
51d9d20b   liuzujun   付费签到,应用市场反馈
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
  		if day <= diffDay then
  			if not curData[day] then
  				curData[day] = 1
  				-- 奖励
  				for itemId, count in pairs(csvData.reward:toNumMap()) do
  					reward[itemId] = (reward[itemId] or 0) + count
  				end
  			end
  		else
  			break
  		end
  	end
  	return reward, curData
  	--if next(reward) then
  		--role.activity:updateActData("PaySignIn", curData)
  		--reward, change = role:award(reward, {log = {desc = "actPaySign"}})
  	--end
  
  	--role:log("activity", {
  	--	activity_id = curData[0], -- 活动ID(或活动指定任务的ID)
  	--	activity_type = role.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表
  	--	activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  	--})
  
  	--SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change)))
  end
  
847f9a7b   liuzujun   兑换活动,邮件内容修改
1011
1012
1013
1014
1015
1016
1017
  -- 回收活动道具
  function Activity:recycleActItem(actId)
  	local role = self.owner
  	local actCfg = csvdb["activity_ctrlCsv"][actId]
  	if not actCfg then return end
  	local gift = {}
  	local costs = {}
1be743f3   liuzujun   扭蛋机调试
1018
  	for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do
847f9a7b   liuzujun   兑换活动,邮件内容修改
1019
1020
1021
1022
  		local fromId, toId, toNum = arr[1], arr[2], arr[3]
  		local itemCount = role:getItemCount(fromId)
  		if itemCount > 0 then
  			costs[fromId] = (costs[fromId] or 0) + itemCount
40dd5057   zhouhaihai   奖励内容错误
1023
  			gift[toId] = (gift[toId] or 0) + toNum * itemCount
847f9a7b   liuzujun   兑换活动,邮件内容修改
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
  		end
  	end
  	if next(costs) then
  		local itemStr = ""
  		for k, v in pairs(costs) do
  			if itemStr ~= "" then
  				itemStr = itemStr .. " "
  			end
  			itemStr = itemStr .. k .. "=" .. v
  		end
  		role:costItems(costs, {log = {desc = "actRecycle"}})
  		role:sendMail(actCfg.recycle_email, nil, gift, {itemStr})
  	end
  end
  
66fe093a   liuzujun   元旦关卡活动
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
  -- 活动挑战关卡计算门票
  function Activity:getBattleTicket(actId)
  	local role = self.owner
  	local createTs = role:getProperty("ctime")
  	local actCfg = csvdb["activity_ctrlCsv"][actId]
  	if not actCfg then return 0 end
  
  	local actStartTime = 0
  	local openTimes = actCfg.time:toArray(false, "=")
  	actStartTime = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME))
  	local actData = self:getActData("ChallengeLevel") or {}
  	local startTs = actData["ts"] or math.max(actStartTime, createTs)
  	local timeNow = skynet.timex()
  	local modify = false
  	local arr = actCfg.condition2:toArray(true, "=")
  
  	local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000
  
  	local count = actData["ticket"] or init
c6a4c456   liuzujun   boss挑战门票购买可以超出上限
1058
1059
1060
1061
1062
  	if count >= limit then
  		actData["ts"] = timeNow
  		self:updateActData("ChallengeLevel", actData)
  		return
  	end
66fe093a   liuzujun   元旦关卡活动
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
  	local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0)
  
  	local newCount= math.min(count + add, limit)
  	if newCount ~= count or newCount >= limit then
  		modify = true
  	end
  	add = newCount - count
  
  	if modify or not next(actData) then
  		actData["ticket"] = newCount
  		actData["ts"] = newCount >= limit and timeNow or (startTs + add * duration * 60)
  		self:updateActData("ChallengeLevel", actData)
  	end
  end
  
0769908c   zhangqijia   feat: 常规世界boss
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
  --常规世界boss计算门票
  function Activity:getRegularWorldBossTicket(actId)
  	local role = self.owner
  	local createTs = role:getProperty("ctime")
  	local actCfg = csvdb["activity_ctrlCsv"][actId]
  	if not actCfg then return 0 end
  
  	local actStartTime = 0
  	local openTimes = actCfg.time:toArray(false, "=")
  	actStartTime = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME))
  	local actData = self:getActData("RegularWorldBoos") or {}
  	local startTs = actData["ts"] or math.max(actStartTime, createTs)
  	local timeNow = skynet.timex()
  	local modify = false
  	local arr = actCfg.condition2:toArray(true, "=")
  
  	local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000
  
  	local count = actData["ticket"] or init
  	if count >= limit then
  		actData["ts"] = timeNow
  		self:updateActData("RegularWorldBoos", actData)
  		return
  	end
  	local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0)
  
  	local newCount= math.min(count + add, limit)
  	if newCount ~= count or newCount >= limit then
  		modify = true
  	end
  	add = newCount - count
  
  	if modify or not next(actData) then
  		actData["ticket"] = newCount
  		actData["ts"] = newCount >= limit and timeNow or (startTs + add * duration * 60)
  		self:updateActData("RegularWorldBoos", actData)
  	end
  end
  
485c8c35   liuzujun   活动礼包购买记录活动过期清理
1117
1118
1119
  activityFunc[Activity.ActivityType.ActShopGoods] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
  	end,
e9c1df55   liuzujun   活动商品结束清购买记录 修改Ema...
1120
  	["close"] = function(self, actType, notify, actId)
485c8c35   liuzujun   活动礼包购买记录活动过期清理
1121
1122
  		local rechargeRecord = self.owner.storeData:getProperty("payR")
  		for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do
e9c1df55   liuzujun   活动商品结束清购买记录 修改Ema...
1123
1124
  			--if cfg.shop == 3 and cfg.type == ShopPackType.ActShopPack then
  			if cfg.activity_id == actId then
485c8c35   liuzujun   活动礼包购买记录活动过期清理
1125
1126
1127
1128
1129
1130
1131
  				rechargeRecord[id] = nil
  			end
  		end
  		self.owner.storeData:updateProperty({field="payR", value=rechargeRecord})
  	end,
  }
  
091912ed   chenyueqi   未测试版好友能量助力活动
1132
1133
  activityFunc[Activity.ActivityType.FriendEnergy] = {
  	["init"] = function (self, actType, isCrossDay, notify, actId)
6a61fe2c   chenyueqi   少个大括号
1134
  		local data = {magic = 0, limit = 0, reward = {}, giveAE = {}, getAE = {}, new = self:getActFriendNew()}
091912ed   chenyueqi   未测试版好友能量助力活动
1135
1136
  		self:updateActData(actType, data, not notify)
  	end,
0886d05a   chenyueqi   修改联动好友赠送获得的红点记录和通知
1137
  	["login"] = function (self, actType)
cab7184b   chenyueqi   活动能量bug
1138
  		local actData = self:getActData(actType) or {}
0886d05a   chenyueqi   修改联动好友赠送获得的红点记录和通知
1139
1140
1141
  		actData.new = self:getActFriendNew()
  		self:updateActData(actType, actData, not notify)
  	end,
091912ed   chenyueqi   未测试版好友能量助力活动
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
  	["crossDay"] = function(self, actType, notify)
  		local actData = self:getActData(actType)
  		actData.limit = 0
  		actData.giveAE = {}
  		actData.getAE = {}
  		self:updateActData(actType, actData, not notify)
  	end,
  	["close"] = function (self, actType, notify, actId)
  		redisproxy:del(FRIEND_ENERGY:format(self.owner:getProperty("id")))
  	end
  }
161c50cc   zhouhaihai   宝藏怪活动
1153
  
cab7184b   chenyueqi   活动能量bug
1154
  function Activity:getActFriendNew()
0886d05a   chenyueqi   修改联动好友赠送获得的红点记录和通知
1155
  	local roleId = self.owner:getProperty("id")
0886d05a   chenyueqi   修改联动好友赠送获得的红点记录和通知
1156
1157
  
  	local ids = {}
cab7184b   chenyueqi   活动能量bug
1158
1159
  	local members = redisproxy:smembers(FRIEND_ENERGY:format(roleId))
  	for _, id in pairs(members) do
6136eaca   liuzujun   添加好友表
1160
  		if self.owner.friends[tonumber(id)] then
cab7184b   chenyueqi   活动能量bug
1161
  			ids[tonumber(id)] = 1
0886d05a   chenyueqi   修改联动好友赠送获得的红点记录和通知
1162
  		end
cab7184b   chenyueqi   活动能量bug
1163
  	end
0886d05a   chenyueqi   修改联动好友赠送获得的红点记录和通知
1164
1165
1166
  	return ids
  end
  
161c50cc   zhouhaihai   宝藏怪活动
1167
1168
1169
1170
1171
1172
1173
  activityFunc[Activity.ActivityType.Crisis] = {
  	["check"] = function(self, actType, notify, atype, count) -- 检查
  		count = count or 1
  		local isOpen, actId = self:isOpen(actType)
  		local actData = self:getActData(actType) or {}
  		actData.task = actData.task or {}
  		local change = false
e8719dc4   zhouhaihai   物资危机bug
1174
  		local actCsv = csvdb["activity_crisisCsv"][actId]
161c50cc   zhouhaihai   宝藏怪活动
1175
1176
1177
  		for id, actSet in pairs(actCsv) do
  			if actSet.type == atype then
  				local status = actData.task[id] or 0
bb30b1c1   zhouhaihai   宝藏怪
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
  				if status ~= -1 then
  					status = status + count
  					if status >= actSet.condition1 then
  						local reward
  						if actSet.loop == 1 then
  							local rcount = math.floor(status / actSet.condition1)
  							reward = actSet.reward:toNumMap()
  							for itemId, itemC in pairs(reward) do
  								reward[itemId] = itemC * rcount
  							end
  							status = status % actSet.condition1
  						else
  							reward = actSet.reward
  							status = -1
161c50cc   zhouhaihai   宝藏怪活动
1192
  						end
b47316e6   zhouhaihai   活动奖励bug
1193
  
0c6b1a62   chenyueqi   物资危机增加 代理拾荒时间和拾荒击...
1194
  						self.owner:award(reward, {log = {desc = "activityCrisis"}, notNotify = not notify})
bb30b1c1   zhouhaihai   宝藏怪
1195
1196
1197
  					end
  					actData.task[id] = status
  					change = true
161c50cc   zhouhaihai   宝藏怪活动
1198
  				end
161c50cc   zhouhaihai   宝藏怪活动
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
  			end
  		end
  		if change then
  			-- 更新下排行榜
  			self.owner:updateRankCommon(RANK_TYPE.ActCrisis, self.owner:getItemCount(ItemId.CrisisScore))
  			self:updateActData(actType, actData)
  		end
  	end,
  }
  
ac885527   liuzujun   联动签到活动
1209
1210
1211
1212
  activityFunc[Activity.ActivityType.CommonSignIn] = {
  	["init"] = function(self, actType, isCrossDay, notify, actId)
  		if not isCrossDay then
  			activityFunc[Activity.ActivityType.CommonSignIn]["crossDay"](self, actType, notify, actId)
115454c1   liuzujun   调整咵天清日常与活动初始化的调用顺序
1213
1214
1215
  
  			local taskStatus = self.owner:getProperty("dTask")
  			activityFunc[Activity.ActivityType.CommonSignIn]["check"](self, actType, notify, 0, (taskStatus["a"] or 0))
ac885527   liuzujun   联动签到活动
1216
  		end
ac885527   liuzujun   联动签到活动
1217
1218
1219
1220
  	end,
  	["crossDay"] = function(self, actType, notify, actId)
  		local actCfg = csvdb["activity_ctrlCsv"][actId]
  		if not actCfg then return end
86a873b9   liuzujun   活动任务数据重置
1221
  		local conArr = actCfg.condition2:toArray(true, "=")
ac885527   liuzujun   联动签到活动
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
  		-- 0 登录即可, 1 达到指定活跃度
  		if conArr[1] ~= 0 then
  			return
  		end
  		local curData = self:getActData(actType) or {}
  		curData[0] = (curData[0] or 0) + 1
  		self:updateActData(actType, curData, not notify)
  	end,
  	["check"] = function(self, actType, notify, pre, cur) -- 检查
  		local isOpen, actId = self:isOpen(actType)
  		local actData = self:getActData(actType) or {}
  		local actCfg = csvdb["activity_ctrlCsv"][actId]
  		if not actCfg then return end
dfa9ae5e   liuzujun   战令任务活动
1235
  		local conArr = actCfg.condition2:toArray(true, "=")
ac885527   liuzujun   联动签到活动
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
  		-- 0 登录即可, 1 达到指定活跃度
  		if conArr[1] ~= 1 then
  			return
  		end
  		local val = conArr[2] or 0
  		if pre < val and cur >= val then
  			actData[0] = (actData[0] or 0) + 1
  			self:updateActData(actType, actData, not notify)
  		end
  	end,
  }
  
c756d4df   liuzujun   新年将军令活动
1248
1249
  activityFunc[Activity.ActivityType.BattleCommand] = {
  	["init"] = function (self, actType, isCrossDay, notify, actId)
dfa9ae5e   liuzujun   战令任务活动
1250
  		local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0, week = 0}
c756d4df   liuzujun   新年将军令活动
1251
  		self:updateActData(actType, data, not notify)
8eaed74e   liuzujun   战令活动开启时清除购买记录,新增B...
1252
1253
1254
1255
1256
1257
1258
1259
  
  		local rechargeRecord = self.owner.storeData:getProperty("payR")
  		for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do
  			if cfg.shop == 2 and cfg.type == CardType.ActBattleCommandCard then
  				rechargeRecord[id] = nil
  			end
  		end
  		self.owner.storeData:updateProperty({field="payR", value=rechargeRecord})
c756d4df   liuzujun   新年将军令活动
1260
  	end,
b620581a   liuzujun   战令活动,战令相关的任务活动
1261
  	["check"] = function(self, actType, notify, id, count) -- 检查	itemid, count
c756d4df   liuzujun   新年将军令活动
1262
1263
1264
1265
1266
  		local isOpen, actId = self:isOpen(actType)
  		local actData = self:getActData(actType) or {}
  		local actCfg = csvdb["activity_ctrlCsv"][actId]
  		if not actCfg then return end
  		if actCfg.condition1 == "" then return end
dfa9ae5e   liuzujun   战令任务活动
1267
  		local arr = actCfg.condition2:toArray(true, "=")
75876cb3   liuzujun   代理拾荒出勤人数计数错误, 代理拾...
1268
1269
1270
1271
1272
1273
  		local itemIdWeek, itemIdNormal, limit = arr[1], arr[2], arr[3]
  		if (itemIdWeek == id or itemIdNormal == id) and count > 0 then
  			if itemIdWeek == id then
  				if (actData["week"] or 0) >= limit then
  					return
  				end
e3b29f2f   liuzujun   战令-一次性领取超出周上限的战令经...
1274
1275
1276
  				local old = actData["week"] or 0
  				actData["week"] = math.min(old + count, limit)
  				count = actData["week"] - old
dfa9ae5e   liuzujun   战令任务活动
1277
  			end
3f9b3dbf   zhangqijia   fix: 战令活动,sum字段判空 。
1278
  			local total = (actData["sum"] or 0) + count
b620581a   liuzujun   战令活动,战令相关的任务活动
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
  			local curLvl = actData["lvl"] or 0
  			if actCfg.condition == 1 then		-- 代表sum需要转换为等级
  				local bpCfg = csvdb["activity_battlepass_rewardCsv"][actId]
  				if not bpCfg then return end
  				for i = 1, #bpCfg do
  					local cfg = bpCfg[i]
  					if cfg["type"] > curLvl then
  						if total < cfg["condition"] then break end
  						total = total - cfg["condition"]
  						curLvl = curLvl + 1
  					end
  				end
  				actData["lvl"] = curLvl
  				actData["sum"] = total
  			end
  
c756d4df   liuzujun   新年将军令活动
1295
1296
1297
  			self:updateActData(actType, actData)
  		end
  	end,
dfa9ae5e   liuzujun   战令任务活动
1298
1299
1300
1301
1302
  	["crossWeek"] = function(self, actType, notify, actId)
  		local actData = self:getActData(actType) or {}
  		actData["week"] = 0
  		self:updateActData(actType, actData, true)
  	end,
30f12b27   liuzujun   战令活动过期清购买记录, 升级月卡...
1303
1304
1305
1306
1307
1308
1309
1310
1311
  	["close"] = function (self, actType, notify, actId)
  		local rechargeRecord = self.owner.storeData:getProperty("payR")
  		for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do
  			if cfg.shop == 2 and cfg.type == CardType.ActBattleCommandCard then
  				rechargeRecord[id] = nil
  			end
  		end
  		self.owner.storeData:updateProperty({field="payR", value=rechargeRecord})
  	end,
c756d4df   liuzujun   新年将军令活动
1312
1313
1314
  }
  
  
336fa4a6   chenyueqi   新的活动签到,新春三重奏之返还0消耗
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
  activityFunc[Activity.ActivityType.NewSign] = {
  	-- ["check"] = function(self, actType, notify) -- 检查
  	-- end,
  	["init"] = function(self, actType, isCrossDay, notify)
  		if not isCrossDay then
  			activityFunc[Activity.ActivityType.NewSign]["crossDay"](self, actType, notify)
  		end
  	end,
  	-- ["close"] = function(self, actType, notify)
  	-- end,
  	["crossDay"] = function(self, actType, notify)
  		local curData = self:getActData(actType)
1d7517e6   chenyueqi   新春签到代码优化,支持不同时开同类...
1327
1328
1329
1330
1331
  		local isOpen, actId = self:isOpen(actType)
  		local actData = csvdb["activity_signInCsv"][actId] or {}
  		curData["0"] = curData["0"] or 0
  		if curData["0"] >= #actData then return end -- 满了就忽略了
  		curData["0"] = curData["0"] + 1
336fa4a6   chenyueqi   新的活动签到,新春三重奏之返还0消耗
1332
1333
1334
1335
1336
1337
  
  		-- 没满更新一下
  		self:updateActData(actType, curData, not notify)
  	end,
  }
  
43a6d57e   liuzujun   拾荒活动
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
  local function closeActAdvHang(role, chapterId)
  	local advHang = role:getProperty("advHang")
  	local info = advHang[chapterId]
  	if not info then return end
  
  	local index = info.index or 1
  	local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId]
  	if not chapterData then return end
  	local campSiteData = chapterData[info.campId or 2]
  	if not campSiteData then return 1 end
  	if campSiteData.idleReward_1 == "" and campSiteData.idleReward_2 == "" then return 2 end --没有奖励 没有挂机
  
  	local adv_idle_time = globalCsv.adv_idle_time[index]
  	local adv_idle_energy = globalCsv.adv_idle_energy[index]
  	local adv_idle_reward_coef = globalCsv.adv_idle_reward[index]
  	if not adv_idle_time or not adv_idle_energy or not adv_idle_reward_coef then
  		return 2
  	end
  	adv_idle_time = adv_idle_time * 60
  	
  	local reward, isFull, change, heroFaithMap
  	local heroCnt = 0
  	if skynet.timex() >= info.time then
  		-- 增加英雄信赖
  		local exp = info.duration / 60
  		heroFaithMap = {}
  		for _, heroId in pairs(info.format.heros) do
  			local curFaith = role:addHeroFaith(heroId, exp)
  			heroFaithMap[heroId] = curFaith
  			heroCnt = heroCnt + 1
  		end
  
  		local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
  
  		local idleReward = totalReward:toNumMap()
  		for itemId, count in pairs(idleReward) do
  			idleReward[itemId] = count * adv_idle_reward_coef
  		end
  		reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}})
  	end
43a6d57e   liuzujun   拾荒活动
1378
1379
1380
1381
1382
1383
1384
1385
  	role:changeUpdates({{type = "advHang", field = chapterId, value = nil}})
  
  	role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = 2})
  
  	role:checkTaskEnter("AdvHang", {})
  	role:checkTaskEnter("AdvHangHeroCnt", {count = heroCnt})
  end
  
98be031a   liuzujun   新年活动
1386
1387
1388
1389
1390
1391
1392
1393
  activityFunc[Activity.ActivityType.AdvLevel] = {
  	-- ["check"] = function(self, actType, notify) -- 检查
  	-- end,
  	["init"] = function(self, actType, isCrossDay, notify)
  	end,
  	["close"] = function(self, actType, notify, actid)
  		local actCfg = csvdb["activity_adv_chapterCsv"][actid]
  		if not actCfg then return end
1a20d90b   liuzujun   添加活动关卡gm指令, 活动代理拾...
1394
  		for chapterId, _ in pairs(actCfg) do
98be031a   liuzujun   新年活动
1395
1396
  			local advPass = self.owner:getProperty("advPass")
  			advPass[chapterId] = nil
f037f9c3   zhouhaihai   充值中继, 关闭缺少参数
1397
1398
1399
1400
1401
1402
  			local advRelay = self.owner:getProperty("advRelay")
  			advRelay[chapterId] = nil
  			self.owner:updateProperties({
  				advPass = advPass,
  				advRelay = advRelay,
  			}, not notify)
43a6d57e   liuzujun   拾荒活动
1403
  			-- 关闭活动代理拾荒
f037f9c3   zhouhaihai   充值中继, 关闭缺少参数
1404
  			closeActAdvHang(self.owner, chapterId)
43a6d57e   liuzujun   拾荒活动
1405
1406
  		end
  		-- 强制关闭活动拾荒关卡
edd92fd9   liuzujun   活动拾荒活动结束重置数据
1407
  		local adv = self.owner:getAdvData()
43a6d57e   liuzujun   拾荒活动
1408
1409
  		if adv:isRunning() and adv:isActivity() then
  			adv:forceOver()
98be031a   liuzujun   新年活动
1410
  		end
43a6d57e   liuzujun   拾荒活动
1411
  
98be031a   liuzujun   新年活动
1412
1413
1414
  	end,
  }
  
21581e1f   liuzujun   新增 电台类活动
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
  -- 获取英雄大成功率
  local function getHeroCoef(hero, condition)
      -- 基础概率
      local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20}
      local rare = hero:getRare()
      local result = 0
      for _, it in ipairs(condition:toTableArray(true)) do
          local type = it[1]
          local value = it[2]
          local add = it[3]
          if type == 1 then   -- 种族加成
              if hero:getCamp() == value then
                  result = result + add
              end
          elseif type == 2 then   -- 定位加成
              if hero:getPosition() == value then
                  result = result + add
              end
          end
      end
  
      return result + (rareMap[rare] or 0)
  end
  
  local function getActRadioTaskReward(role, id, task)
      local config = csvdb["crusadeCsv"][id]
      if not config then return 2 end
      local carbonData = csvdb["idle_battleCsv"][config.unlock]
      if not carbonData then return 3 end
      --  get heros
      local totalCoef = 0
      local exp = config.time / 60
      for _, heroId in ipairs(task.heros) do
          local hero = role.heros[heroId]
          if hero then
              totalCoef = totalCoef + getHeroCoef(hero, config.success)
              -- 增加英雄信赖
              hero:addHeroFaith(exp)
          end
      end
      -- send award
      local bigSuccess = false
      local result = math.randomInt(0, 100)
      if result < totalCoef then
          bigSuccess = true
      end
      local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear
      local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear
      local itemReward = config.item_clear_special:toNumMap()
      itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money
      itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp
      if bigSuccess then
          for key, value in pairs(itemReward) do
              itemReward[key] = math.ceil(1.5 * value)
          end
      end
  
  	return itemReward
  end
  
  
  activityFunc[Activity.ActivityType.RadioTask] = {
  	-- ["check"] = function(self, actType, notify) -- 检查
  	-- end,
  	["init"] = function(self, actType, isCrossDay, notify)
  	end,
  	["close"] = function(self, actType, notify, actid)
  		local radioTask = self.owner:getProperty("radioTask")
  		local result = {}
  		for id, task in pairs(radioTask) do
  			--  check id
  			local config = csvdb["crusadeCsv"][id]
  			if config then 
5204a839   liuzujun   活动电台任务结束时候清理任务
1488
  				if config.activity_ctrl_id == actid then 
21581e1f   liuzujun   新增 电台类活动
1489
1490
  					radioTask[id] = nil
  
7d5e688f   liuzujun   临时清除活动电台任务
1491
1492
1493
1494
1495
1496
1497
  					if task then 
  						if skynet.timex() > task.time then 
  							local reward = getActRadioTaskReward(self.owner, id, task)
  							for k, v in pairs(reward) do
  								result[k] = (result[k] or 0) + v
  							end
  						end
21581e1f   liuzujun   新增 电台类活动
1498
1499
1500
1501
1502
1503
1504
1505
1506
  					end
  				end
  			end
  		end
  		self.owner:sendMail(MailId.ActRadoTaskReward, nil, result, nil)
  		self.owner:updateProperty({field="radioTask", value=radioTask, notNotify = true})
  	end,
  }
  
706b517e   liuzujun   翻倍掉落活动,商城免费宝箱
1507
  return Activity