d763fb14
zhouhaihai
签到 九宫格
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
local ipairs = ipairs
local table = table
local math = math
local string = string
local redisproxy = redisproxy
local MsgPack = MsgPack
local string_format = string.format
local tonumber = tonumber
local table_insert = table.insert
local table_unpack = table.unpack
local table_find = table.find
local table_nums = table.nums
local math_random = math.randomInt
local _M = {}
function _M.sudokuRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local id = msg.id
local sudoku = role:getProperty("sudoku")
local phase = sudoku[-1] or 1
local curData = (csvdb["guide_sudokuCsv"][phase] or {})[id]
if phase == -1 or not curData then return 1 end
sudoku.task = sudoku.task or {}
sudoku.task[phase] = sudoku.task[phase] or {}
if (sudoku.task[phase][id] or 0) < curData.con1 then return 2 end
sudoku.task[phase][id] = -1
|
7bb30dca
zhouhaihai
修改发奖
|
35
|
local task, tchange = role:award(curData.reward, {log = {desc = "sudoku", int1 = id, int2 = phase}}) -- 任务奖励
|
d763fb14
zhouhaihai
签到 九宫格
|
36
|
|
7bb30dca
zhouhaihai
修改发奖
|
37
|
local reward, rchange = {}
|
d763fb14
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
|
local rId = {}
for pid, pdata in pairs(csvdb["guide_sudoku_rewardCsv"][phase] or {}) do
local pos = pdata.pos:toArray(true, "=")
local ok, is = true, false
for _, one in pairs(pos) do
if one == id then
is = true
end
if sudoku.task[phase][one] ~= -1 then
ok = false
break
end
end
if ok and is then
for itemId, count in pairs(pdata.reward:toNumMap()) do
reward[itemId] = (reward[itemId] or 0) + count
end
table.insert(rId, pid)
end
end
if not next(reward) then
reward = nil
else
|
7bb30dca
zhouhaihai
修改发奖
|
63
|
reward, rchange = role:award(reward, {log = {desc = "sudokuR", int1 = id, int2 = phase}})
|
d763fb14
zhouhaihai
签到 九宫格
|
64
65
66
67
|
end
role:updateProperty({field = "sudoku", value = sudoku})
|
c59e058b
zhouhaihai
新一批日志记录
|
68
69
70
|
role:log("activity", {
activity_id = id, -- 活动ID(或活动指定任务的ID)
activity_type = 0, -- 活动类型,见活动类型枚举表
|
56c7a1c5
liuzujun
修改报错,下载cv奖励记录字段
|
71
|
activity_reward = reward or {}, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
72
|
})
|
f22a33af
zhouhaihai
自己的日志
|
73
|
role:mylog("act_action", {desc = "sudoku", int1 = id, int2 = phase})
|
d763fb14
zhouhaihai
签到 九宫格
|
74
|
|
7bb30dca
zhouhaihai
修改发奖
|
75
|
SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = role:packReward(task, tchange), reward = role:packReward(reward, rchange), rId = rId}))
|
d763fb14
zhouhaihai
签到 九宫格
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
return true
end
function _M.sudokuRewardRpc(agent, data)
local role = agent.role
local sudoku = role:getProperty("sudoku")
local phase = sudoku[-1] or 1
local curData = csvdb["guide_sudokuCsv"][phase]
if not curData then return end
if not globalCsv.guide_sudoku_reward[phase] then return end
local curTask = (sudoku.task or {})[phase] or {}
for id, _ in pairs(curData) do
if curTask[id] ~= -1 then
return
end
end
|
7bb30dca
zhouhaihai
修改发奖
|
98
|
local reward, change = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}})
|
d763fb14
zhouhaihai
签到 九宫格
|
99
100
101
102
103
104
105
106
107
|
sudoku[-1] = phase + 1
sudoku.task[phase] = nil
if not csvdb["guide_sudokuCsv"][sudoku[-1]] then
sudoku[-1] = -1
sudoku.task = nil
end
role:updateProperty({field = "sudoku", value = sudoku})
|
c59e058b
zhouhaihai
新一批日志记录
|
108
109
110
|
role:log("activity", {
activity_id = 10000 + phase, -- 活动ID(或活动指定任务的ID)
activity_type = 0, -- 活动类型,见活动类型枚举表
|
887c1843
zhouhaihai
日志新一批
|
111
|
activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
112
113
|
})
|
7bb30dca
zhouhaihai
修改发奖
|
114
|
SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(role:packReward(reward, change)))
|
d763fb14
zhouhaihai
签到 九宫格
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
return true
end
function _M.signRpc(agent, data)
local role = agent.role
local serverT = skynet.timex()
local tm = os.date("*t", serverT)
local curDay = tm.day
local yearMonth = tm.year * 100 + tm.month
local monthData = csvdb["daily_signInCsv"][yearMonth]
if not monthData or not monthData[curDay] then
return 1
end
local signs = role:getProperty("sign")
if signs[curDay] == yearMonth then -- 未重置的还可以签到正常(本月已经签到)
return 2
end
signs[curDay] = yearMonth
|
7bb30dca
zhouhaihai
修改发奖
|
139
|
local reward, change = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}})
|
d763fb14
zhouhaihai
签到 九宫格
|
140
|
role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}})
|
e7806e6f
zhouhaihai
签到成就
|
141
|
role:checkTaskEnter("SignIn")
|
d763fb14
zhouhaihai
签到 九宫格
|
142
|
|
7bb30dca
zhouhaihai
修改发奖
|
143
|
SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(role:packReward(reward, change)))
|
d763fb14
zhouhaihai
签到 九宫格
|
144
145
146
147
|
return true
end
|
ea40710f
zhouhaihai
活动
|
148
149
|
function _M.actSignRpc(agent, data)
local role = agent.role
|
be4e8031
zhouhaihai
活动 拾荒
|
150
|
if not role.activity:isOpen("Sign") then return 1 end
|
ea40710f
zhouhaihai
活动
|
151
152
|
local curData = role.activity:getActData("Sign")
|
7bb30dca
zhouhaihai
修改发奖
|
153
|
local reward, change = {}
|
be4e8031
zhouhaihai
活动 拾荒
|
154
|
for day, csvData in ipairs(csvdb["new_signInCsv"]) do
|
ea40710f
zhouhaihai
活动
|
155
156
157
158
159
160
161
162
163
164
165
166
167
|
if day <= (curData[0] or 0) 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
if next(reward) then
|
be4e8031
zhouhaihai
活动 拾荒
|
168
|
role.activity:updateActData("Sign", curData)
|
7bb30dca
zhouhaihai
修改发奖
|
169
|
reward, change = role:award(reward, {log = {desc = "actSign"}})
|
ea40710f
zhouhaihai
活动
|
170
|
end
|
c59e058b
zhouhaihai
新一批日志记录
|
171
172
173
174
|
role:log("activity", {
activity_id = curData[0], -- 活动ID(或活动指定任务的ID)
activity_type = role.activity.ActivityType.Sign, -- 活动类型,见活动类型枚举表
|
887c1843
zhouhaihai
日志新一批
|
175
|
activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
176
177
|
})
|
7bb30dca
zhouhaihai
修改发奖
|
178
|
SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(role:packReward(reward, change)))
|
ea40710f
zhouhaihai
活动
|
179
180
181
|
return true
end
|
d763fb14
zhouhaihai
签到 九宫格
|
182
|
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
183
184
185
|
function _M.actPaySignRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
460afa6e
liuzujun
付费签到改为主动领取,战斗关卡不一...
|
186
|
local dayIndex = msg.day
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
187
188
|
local actGoodsFlag = role.storeData:getProperty("actGoodsFlag")
local index = GetActGoodsIndex("paySignIn")
|
460afa6e
liuzujun
付费签到改为主动领取,战斗关卡不一...
|
189
190
|
local ts = actGoodsFlag[index] or 0
if ts == 0 then return 1 end
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
191
|
|
460afa6e
liuzujun
付费签到改为主动领取,战斗关卡不一...
|
192
193
|
local open, actId = role.activity:isOpen("PaySignIn")
if not open then return 2 end
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
194
|
|
460afa6e
liuzujun
付费签到改为主动领取,战斗关卡不一...
|
195
|
local diffDay = diffFromTs(ts) + 1
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
196
197
|
local curData = role.activity:getActData("PaySignIn")
|
b1644d3b
liuzujun
付费签到天数bug
|
198
|
if not curData then return 3 end
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
199
200
|
local reward, change = {}
for day, csvData in ipairs(csvdb["pay_signInCsv"]) do
|
460afa6e
liuzujun
付费签到改为主动领取,战斗关卡不一...
|
201
|
if day <= diffDay and day == dayIndex then
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
202
203
204
205
206
207
208
|
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
|
460afa6e
liuzujun
付费签到改为主动领取,战斗关卡不一...
|
209
210
|
--else
-- break
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
211
212
213
214
215
216
217
218
|
end
end
if next(reward) then
role.activity:updateActData("PaySignIn", curData)
reward, change = role:award(reward, {log = {desc = "actPaySign"}})
end
role:log("activity", {
|
460afa6e
liuzujun
付费签到改为主动领取,战斗关卡不一...
|
219
|
activity_id = actId, -- 活动ID(或活动指定任务的ID)
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
220
221
222
223
224
225
226
|
activity_type = role.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表
activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
})
SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change)))
return true
end
|
d763fb14
zhouhaihai
签到 九宫格
|
227
|
|
4bd3095f
liuzujun
英雄帖任务bug
|
228
|
function _M.actCalendaTaskRpc(agent, data)
|
190e1415
liuzujun
英雄帖活动初始化
|
229
230
231
|
local role = agent.role
local msg = MsgPack.unpack(data)
local taskId = msg.id
|
4bd3095f
liuzujun
英雄帖任务bug
|
232
|
local calTask = role:getProperty("calTask") or {}
|
190e1415
liuzujun
英雄帖活动初始化
|
233
234
235
236
237
238
239
240
|
local record = calTask["r"] or {}
local flag = record[taskId] or 0
if flag == 1 then return 1 end
local open, actId = role.activity:isOpen("CalendaTask")
local actData = csvdb["activity_ctrlCsv"][actId]
if not open then return 2 end
if not actData then return 3 end
|
4bd3095f
liuzujun
英雄帖任务bug
|
241
242
243
244
245
|
local taskList = csvdb["activity_taskCsv"][actData.condition]
if not taskList then return 4 end
local taskCfg = taskList[taskId]
if not taskCfg then return 5 end
if taskCfg.key ~= actData.condition then return 6 end
|
190e1415
liuzujun
英雄帖活动初始化
|
246
|
|
4bd3095f
liuzujun
英雄帖任务bug
|
247
|
if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end
|
190e1415
liuzujun
英雄帖活动初始化
|
248
249
250
251
|
record[taskId] = 1
calTask["r"] = record
|
4bd3095f
liuzujun
英雄帖任务bug
|
252
|
role:updateProperty({field = "calTask", value = calTask})
|
190e1415
liuzujun
英雄帖活动初始化
|
253
|
|
4bd3095f
liuzujun
英雄帖任务bug
|
254
|
local reward, change = role:award(taskCfg.reward, {log = {desc = "calendaTask"}})
|
190e1415
liuzujun
英雄帖活动初始化
|
255
256
257
258
259
260
261
262
|
role:log("activity", {
activity_id = taskId, -- 活动ID(或活动指定任务的ID)
activity_type = role.activity.ActivityType.CalendaTask, -- 活动类型,见活动类型枚举表
activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
})
SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change)))
|
4bd3095f
liuzujun
英雄帖任务bug
|
263
|
return true
|
190e1415
liuzujun
英雄帖活动初始化
|
264
265
|
end
|
847f9a7b
liuzujun
兑换活动,邮件内容修改
|
266
267
268
269
270
|
function _M.exchangeRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local actid = msg.actid
local id = msg.id
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
271
|
if not role.activity:isOpenById(actid) then return 1 end
|
847f9a7b
liuzujun
兑换活动,邮件内容修改
|
272
273
274
275
276
277
278
279
|
local exchangeCfg = csvdb["activity_exchangeCsv"][actid]
if not exchangeCfg then return 2 end
if not exchangeCfg[id] then return 3 end
local curData = role.activity:getActData("Exchange") or {}
local exchangeData = curData[actid] or {}
local curCount = exchangeData[id] or 0
local actCfg = exchangeCfg[id]
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
280
281
|
local limitArr = actCfg.limit:toArray(true, "=")
if curCount >= limitArr[2] then return 4 end
|
847f9a7b
liuzujun
兑换活动,邮件内容修改
|
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
local costs = actCfg.goods:toNumMap()
if not role:checkItemEnough(costs) then return 5 end
role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}})
curCount = curCount + 1
exchangeData[id] = curCount
curData[actid] = exchangeData
role.activity:updateActData("Exchange", curData)
local reward, change = role:award(actCfg.award, {log = {desc = "actExchange", int1 = actid, int2 = id}})
SendPacket(actionCodes.Activity_exchangeRpc, MsgPack.pack(role:packReward(reward, change)))
return true
end
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
299
300
301
302
|
function _M.gachakonRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local actid = msg.actid
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
303
304
305
306
|
local count = msg.count
if count > 10 then return end
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
307
308
|
if not role.activity:isOpenById(actid) then return 1 end
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
309
310
311
312
|
local actCtrlData = csvdb["activity_ctrlCsv"][actid]
if not actCtrlData then return 2 end
local cost = actCtrlData.condition2:toNumMap()
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
313
|
local actCfg = csvdb["activity_capsuleToysCsv"][actid]
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
314
315
|
if not actCfg then return 3 end
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
316
|
local gachakonInfo = role.activity:getActData("Gachakon") or {}
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
317
318
|
local award = {}
local remain = 0
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
319
|
for i = 1, count do
|
1be743f3
liuzujun
扭蛋机调试
|
320
321
322
|
local tmpCfg = clone(actCfg)
remain = 0
print("-----------------, ", i)
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
323
324
|
for id, cfg in pairs(tmpCfg) do
local num = gachakonInfo[id] or 0
|
1be743f3
liuzujun
扭蛋机调试
|
325
326
|
num = cfg.amount >= num and cfg.amount - num or 0
cfg.weight = cfg.weight * num
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
327
|
if cfg.weight > 0 then
|
1be743f3
liuzujun
扭蛋机调试
|
328
|
remain = remain + num
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
329
|
end
|
1be743f3
liuzujun
扭蛋机调试
|
330
|
print("num ".. num, id, cfg.weight, cfg.amount)
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
331
|
end
|
1be743f3
liuzujun
扭蛋机调试
|
332
|
if remain == 0 then
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
333
334
335
|
break
end
local id = math.randWeight(tmpCfg, "weight")
|
1be743f3
liuzujun
扭蛋机调试
|
336
|
if not id then return 4 end
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
337
338
339
340
|
gachakonInfo[id] = (gachakonInfo[id] or 0) + 1
local curAward = tmpCfg[id].award:toNumMap()
for k, v in pairs(curAward) do
award[k] = (award[k] or 0) + v
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
341
|
end
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
342
|
end
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
343
|
|
1be743f3
liuzujun
扭蛋机调试
|
344
345
346
347
348
|
for k, v in pairs(cost) do
cost[k] = v * count
end
if not role:checkItemEnough(cost) then return 5 end
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
349
350
|
role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}})
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
351
|
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
352
|
local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}})
|
1be743f3
liuzujun
扭蛋机调试
|
353
|
if remain <= count then
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
354
|
gachakonInfo = {}
|
1be743f3
liuzujun
扭蛋机调试
|
355
|
print("hahaha")
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
356
|
end
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
357
358
359
360
361
362
|
role.activity:updateActData("Gachakon", gachakonInfo)
SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(role:packReward(reward, change)))
return true
end
|
2bc706ab
liuzujun
兑换活动重置,累充功能
|
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
function _M.hangDropRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local actid = msg.actid
if not role.activity:isOpenById(actid) then return 1 end
local actCfg = csvdb["activity_putCsv"][actid]
if not actCfg then return 2 end
local award, period = "", 0
for i = 1, #actCfg do
local cfg = actCfg[i]
if not cfg then
break
end
if cfg.condition ~= "" then
local arr = cfg.condition:toArray(true, "=")
local type = arr[1]
if type == 1 then
local actId = arr[2]
local carbonId = arr[3]
if not role.activity:isOpenById(actid) then return 3 end
local clInfo = role.activity:getActData("ChallengeLevel") or {}
if not clInfo[carbonId] then
break
end
end
end
award = cfg.reward
period = cfg.period * 60
end
local actData = role.activity:getActData("HangDrop") or 0
local timeNow = skynet.timex()
if period == 0 or award == "" then
return 4
end
local num = math.floor((timeNow - actData)/ period)
num = num > 8 and 8 or num
if num == 0 then
return 5
end
local reward, change = {}, nil
for id, value in pairs(award:toNumMap()) do
reward[id] = value * num
end
reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}})
role.activity:updateActData("HangDrop", timeNow)
SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change)))
return true
end
|
d763fb14
zhouhaihai
签到 九宫格
|
418
|
return _M
|