Commit d9d63fa07bae425365404d2a44c77dcde782fc86

Authored by chenyueqi
1 parent dfc732c5

海港贸易季自动填充,活动结束后的奖励通过邮件发送

Showing 2 changed files with 91 additions and 4 deletions   Show diff stats
src/models/RolePlugin.lua
... ... @@ -1340,8 +1340,7 @@ function RolePlugin.bind(Role)
1340 1340 local donate = seaport.donate or {}
1341 1341 if not reset and (not donate[1] or not donate[2]) then
1342 1342 local result = self:getSeaportServerProgress()
1343   - local seaportCsv = csvdb["seaport_purchaseCsv"]
1344   - for idx, set in ipairs(seaportCsv) do
  1343 + for idx, set in ipairs(csvdb["seaport_purchaseCsv"]) do
1345 1344 local done = true
1346 1345 for id, data in ipairs(set) do
1347 1346 if donate[id] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then
... ... @@ -1351,7 +1350,12 @@ function RolePlugin.bind(Role)
1351 1350 end
1352 1351 if done then
1353 1352 update = true
1354   - self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}})
  1353 + redisproxy:insertEmail({
  1354 + roleId = self:getProperty("id"),
  1355 + emailId = idx == 1 and 361 or 362,
  1356 + attachments = set[1].phase_award,
  1357 + })
  1358 + -- self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}})
1355 1359 donate[idx] = 1
1356 1360 end
1357 1361 end
... ... @@ -1388,6 +1392,8 @@ function RolePlugin.bind(Role)
1388 1392 local expCarbonId = self:getProperty("hangInfo").expCarbonId
1389 1393 local taskCsv = csvdb["seaport_taskCsv"]
1390 1394 local endTime = openTime0 + 86400 * 2
  1395 + local reward = {}
  1396 +
1391 1397 for slot, set in pairs(taskCsv) do
1392 1398 if collect[slot] then
1393 1399 update = true
... ... @@ -1424,9 +1430,28 @@ function RolePlugin.bind(Role)
1424 1430 itemReward[key] = math.ceil(1.5 * value)
1425 1431 end
1426 1432 end
1427   - self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}})
  1433 +
  1434 + for itemId, value in pairs(itemReward) do
  1435 + reward[itemId] = (reward[itemId] or 0) + value
  1436 + end
  1437 + -- self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}})
  1438 + end
  1439 + end
  1440 + end
  1441 +
  1442 + if next(reward) then
  1443 + local rewardStr = ""
  1444 + for itemId, value in pairs(reward) do
  1445 + if rewardStr ~= "" then
  1446 + rewardStr = rewardStr .. " "
1428 1447 end
  1448 + rewardStr = rewardStr .. string.format("%s=%s",itemId,value)
1429 1449 end
  1450 + redisproxy:insertEmail({
  1451 + roleId = self:getProperty("id"),
  1452 + emailId = 363,
  1453 + attachments = rewardStr,
  1454 + })
1430 1455 end
1431 1456 end
1432 1457 seaport.collect = {}
... ...
src/services/globald.lua
... ... @@ -184,6 +184,67 @@ local function check_trade_seaport_status()
184 184 skynet.timeout(interval, check_trade_seaport_status)
185 185 end
186 186  
  187 +-- @desc: 海港贸易捐赠作弊
  188 +local seaportTimes = {}
  189 +local function check_trade_seaport_donate()
  190 + local time1 = tonumber(redisproxy:hget("autoincrement_set", "seaportTime1")) or 0
  191 + local time2 = tonumber(redisproxy:hget("autoincrement_set", "seaportTime2")) or 0
  192 + if time1 == 0 and time2 == 0 then
  193 + seaportTimes = {}
  194 + skynet.timeout(360000, check_trade_seaport_donate)
  195 + return
  196 + end
  197 +
  198 + local csvdb = require "shared.csvdata"
  199 + local donateCsv = csvdb["seaport_purchaseCsv"]
  200 +
  201 + local times = {time1, time2}
  202 + for phase, open in ipairs(times) do
  203 + if open == 1 and not seaportTimes[phase] then
  204 + seaportTimes[phase] = {}
  205 + for _, _ in ipairs(donateCsv[phase]) do
  206 + table.insert(seaportTimes[phase],math.randomInt(1800, 3600))
  207 + end
  208 + end
  209 + end
  210 +
  211 + local interval = 3600
  212 + local phase, id = 0, 0
  213 +
  214 + for key1, data in ipairs(seaportTimes) do
  215 + for key2, temp in pairs(data) do
  216 + if times[key1] == 1 and temp < interval then
  217 + interval = temp
  218 + phase = key1
  219 + id = key2
  220 + end
  221 + end
  222 + end
  223 +
  224 + for _, data in ipairs(seaportTimes) do
  225 + for id, temp in pairs(data) do
  226 + data[id] = temp - interval
  227 + if data[id] == 0 then
  228 + data[id] = math.randomInt(1800, 3600)
  229 + end
  230 + end
  231 + end
  232 +
  233 + if phase ~= 0 and id ~= 0 then
  234 + local redisKeys = {SEAPORT_TRADE_TASK_1,SEAPORT_TRADE_TASK_2}
  235 + local all = donateCsv[phase][id].need_num
  236 + local old = tonumber(redisproxy:hget(redisKeys[phase],id)) or 0
  237 + local add = math.min(math.randomInt(math.floor(all/20),math.floor(all/12)),all - old)
  238 + if add > 0 then
  239 + redisproxy:hincrby(redisKeys[phase],id,add)
  240 + else
  241 + seaportTimes[phase][id] = nil
  242 + end
  243 + end
  244 +
  245 + skynet.timeout(interval * 100, check_trade_seaport_donate)
  246 +end
  247 +
187 248 local CMD = {}
188 249  
189 250  
... ... @@ -208,6 +269,7 @@ function CMD.start()
208 269 check_mail_queue()
209 270 --check_battle_act_close()
210 271 check_trade_seaport_status()
  272 + check_trade_seaport_donate()
211 273 end
212 274  
213 275 local function __init__()
... ...