Commit 847f9a7b1e3f63a31d92dd8ea964ea0ece978206
1 parent
fe296849
兑换活动,邮件内容修改
Showing
9 changed files
with
121 additions
and
8 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
| ... | ... | @@ -50,6 +50,7 @@ actionCodes = { |
| 50 | 50 | Role_useSelectItemRpc = 134, -- 使用多选一礼包 |
| 51 | 51 | Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 |
| 52 | 52 | Role_renameTeamRpc = 136, -- 编队改名 |
| 53 | + Role_accuseRpc = 137, -- 举报 | |
| 53 | 54 | |
| 54 | 55 | Adv_startAdvRpc = 151, |
| 55 | 56 | Adv_startHangRpc = 152, |
| ... | ... | @@ -217,6 +218,7 @@ actionCodes = { |
| 217 | 218 | Activity_actPaySignRewardNtf = 654, |
| 218 | 219 | Activity_actCalendaTaskRpc = 655, |
| 219 | 220 | Activity_actPaySignRpc = 656, |
| 221 | + Activity_exchangeRpc = 657, | |
| 220 | 222 | |
| 221 | 223 | Radio_startQuestRpc = 700, |
| 222 | 224 | Radio_finishQuestRpc = 701, | ... | ... |
src/actions/ActivityAction.lua
| ... | ... | @@ -263,4 +263,36 @@ function _M.actCalendaTaskRpc(agent, data) |
| 263 | 263 | return true |
| 264 | 264 | end |
| 265 | 265 | |
| 266 | +function _M.exchangeRpc(agent, data) | |
| 267 | + local role = agent.role | |
| 268 | + local msg = MsgPack.unpack(data) | |
| 269 | + local actid = msg.actid | |
| 270 | + local id = msg.id | |
| 271 | + if not role.activity:isOpen("Exchange") then return 1 end | |
| 272 | + | |
| 273 | + local exchangeCfg = csvdb["activity_exchangeCsv"][actid] | |
| 274 | + if not exchangeCfg then return 2 end | |
| 275 | + if not exchangeCfg[id] then return 3 end | |
| 276 | + local curData = role.activity:getActData("Exchange") or {} | |
| 277 | + local exchangeData = curData[actid] or {} | |
| 278 | + local curCount = exchangeData[id] or 0 | |
| 279 | + local actCfg = exchangeCfg[id] | |
| 280 | + if curCount >= actCfg then return 4 end | |
| 281 | + | |
| 282 | + local costs = actCfg.goods:toNumMap() | |
| 283 | + if not role:checkItemEnough(costs) then return 5 end | |
| 284 | + role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) | |
| 285 | + | |
| 286 | + curCount = curCount + 1 | |
| 287 | + exchangeData[id] = curCount | |
| 288 | + curData[actid] = exchangeData | |
| 289 | + role.activity:updateActData("Exchange", curData) | |
| 290 | + | |
| 291 | + local reward, change = role:award(actCfg.award, {log = {desc = "actExchange", int1 = actid, int2 = id}}) | |
| 292 | + | |
| 293 | + | |
| 294 | + SendPacket(actionCodes.Activity_exchangeRpc, MsgPack.pack(role:packReward(reward, change))) | |
| 295 | + return true | |
| 296 | +end | |
| 297 | + | |
| 266 | 298 | return _M |
| 267 | 299 | \ No newline at end of file | ... | ... |
src/actions/GmAction.lua
| ... | ... | @@ -533,7 +533,8 @@ function _M.test(role, pms) |
| 533 | 533 | local id = tonum(pms.pm1, 0) |
| 534 | 534 | --local hero = require ("actions.HeroAction") |
| 535 | 535 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
| 536 | - print(role:getPaybackReward(0, 10000)) | |
| 536 | + | |
| 537 | + role:sendMail(13, nil, "1=2", {111}) | |
| 537 | 538 | return "成功" |
| 538 | 539 | end |
| 539 | 540 | ... | ... |
src/actions/RoleAction.lua
| ... | ... | @@ -1279,4 +1279,15 @@ function _M.renameTeamRpc(agent, data) |
| 1279 | 1279 | return true |
| 1280 | 1280 | end |
| 1281 | 1281 | |
| 1282 | +function _M.accuseRpc(agent, data) | |
| 1283 | + local role = agent.role | |
| 1284 | + local msg = MsgPack.unpack(data) | |
| 1285 | + local targetId = msg.targetId | |
| 1286 | + local atype = msg.type | |
| 1287 | + local note = msg.note | |
| 1288 | + | |
| 1289 | + role:mylog("role_action", {desc = "accuse", int1 = targetId, short1 = atype, text1 = note}) | |
| 1290 | + return true | |
| 1291 | +end | |
| 1292 | + | |
| 1282 | 1293 | return _M |
| 1283 | 1294 | \ No newline at end of file | ... | ... |
src/models/Activity.lua
| ... | ... | @@ -19,6 +19,11 @@ Activity.ActivityType = { |
| 19 | 19 | AdvDraw = 13, --拾荒抽周 资助 |
| 20 | 20 | OpenBox = 14, --拆解周 时钟箱 |
| 21 | 21 | RaceDraw = 16, -- 定向招募活动 |
| 22 | + | |
| 23 | + ChallengeLevel = 17, -- 挑战关卡活动 | |
| 24 | + Exchange = 18, -- 兑换活动 | |
| 25 | + HangDrop = 19, -- 挂机掉落活动 | |
| 26 | + Gachakon = 20, -- 扭蛋活动 | |
| 22 | 27 | } |
| 23 | 28 | |
| 24 | 29 | |
| ... | ... | @@ -48,6 +53,11 @@ Activity.schema = { |
| 48 | 53 | act12 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励 |
| 49 | 54 | act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 |
| 50 | 55 | act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 |
| 56 | + | |
| 57 | + act20 = {"table", {}, true}, -- {id=兑换数量} | |
| 58 | + act21 = {"table", {}}, -- {id=抽取的数量} | |
| 59 | + act22 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} | |
| 60 | + act23 = {"table", {}}, -- {挂机信息} | |
| 51 | 61 | } |
| 52 | 62 | |
| 53 | 63 | function Activity:data() |
| ... | ... | @@ -409,12 +419,34 @@ activityFunc[Activity.ActivityType.CalendaTask] = { |
| 409 | 419 | -- end, |
| 410 | 420 | } |
| 411 | 421 | |
| 422 | +-- 兑换 | |
| 423 | +activityFunc[Activity.ActivityType.Exchange] = { | |
| 424 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
| 425 | + local role = self.owner | |
| 426 | + local actData = self:getActData(actType) or {} | |
| 427 | + actData[actId] = {} | |
| 428 | + self:updateActData(actType, actData, not notify) | |
| 429 | + end, | |
| 430 | + --["close"] = function(self, actType, notify, actId) | |
| 431 | + --end, | |
| 432 | +} | |
| 433 | + | |
| 434 | +-- 扭蛋机 | |
| 435 | +activityFunc[Activity.ActivityType.Gachakon] = { | |
| 436 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
| 437 | + self:updateActData(actType, {}, not notify) | |
| 438 | + end, | |
| 439 | + ["crossDay"] = function(self, actType, notify) | |
| 440 | + self:updateActData(actType, {}, not notify) | |
| 441 | + end, | |
| 442 | +} | |
| 443 | + | |
| 412 | 444 | function Activity:initActivity(actId, isCrossDay, notify) |
| 413 | 445 | local actData = csvdb["activity_ctrlCsv"][actId] |
| 414 | 446 | if not actData then return end |
| 415 | 447 | local actType = actData.showType |
| 416 | 448 | if activityFunc[actType] and activityFunc[actType]['close'] then |
| 417 | - activityFunc[actType]["init"](self, actType, isCrossDay, notify) | |
| 449 | + activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId) | |
| 418 | 450 | end |
| 419 | 451 | end |
| 420 | 452 | |
| ... | ... | @@ -423,7 +455,8 @@ function Activity:closeActivity(actId, notify, notUpdateAct) |
| 423 | 455 | if not actData then return end |
| 424 | 456 | local actType = actData.showType |
| 425 | 457 | if activityFunc[actType] and activityFunc[actType]['close'] then |
| 426 | - activityFunc[actType]["close"](self, actType, notify) | |
| 458 | + activityFunc[actType]["close"](self, actType, notify, actId) | |
| 459 | + self:recycleActItem(actId) | |
| 427 | 460 | end |
| 428 | 461 | if Activity.schema["act".. actType] then |
| 429 | 462 | self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) |
| ... | ... | @@ -529,5 +562,33 @@ function Activity:getPaySignReward() |
| 529 | 562 | --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change))) |
| 530 | 563 | end |
| 531 | 564 | |
| 565 | +-- 回收活动道具 | |
| 566 | +function Activity:recycleActItem(actId) | |
| 567 | + local role = self.owner | |
| 568 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | |
| 569 | + if not actCfg then return end | |
| 570 | + local gift = {} | |
| 571 | + local costs = {} | |
| 572 | + for _, arr in ipairs(role:getItemCount(actCfg.recycle):toTableArray(true)) do | |
| 573 | + local fromId, toId, toNum = arr[1], arr[2], arr[3] | |
| 574 | + local itemCount = role:getItemCount(fromId) | |
| 575 | + if itemCount > 0 then | |
| 576 | + costs[fromId] = (costs[fromId] or 0) + itemCount | |
| 577 | + gift[toId] = toNum * itemCount | |
| 578 | + end | |
| 579 | + end | |
| 580 | + if next(costs) then | |
| 581 | + local itemStr = "" | |
| 582 | + for k, v in pairs(costs) do | |
| 583 | + if itemStr ~= "" then | |
| 584 | + itemStr = itemStr .. " " | |
| 585 | + end | |
| 586 | + itemStr = itemStr .. k .. "=" .. v | |
| 587 | + end | |
| 588 | + role:costItems(costs, {log = {desc = "actRecycle"}}) | |
| 589 | + role:sendMail(actCfg.recycle_email, nil, gift, {itemStr}) | |
| 590 | + end | |
| 591 | +end | |
| 592 | + | |
| 532 | 593 | |
| 533 | 594 | return Activity | ... | ... |
src/models/Email.lua
| ... | ... | @@ -48,10 +48,10 @@ function Email:data() |
| 48 | 48 | |
| 49 | 49 | if emailData then |
| 50 | 50 | -- 如果内容是直接插入到数据库 |
| 51 | - if content == "" and emailData.body ~= "" then | |
| 52 | - content = io.readfile("src/" .. emailData.body) or "" | |
| 53 | - content = content:format(table.unpack(contentPms)) | |
| 54 | - end | |
| 51 | + --if content == "" and emailData.body ~= "" then | |
| 52 | + -- content = io.readfile("src/" .. emailData.body) or "" | |
| 53 | + -- content = content:format(table.unpack(contentPms)) | |
| 54 | + --end | |
| 55 | 55 | |
| 56 | 56 | if title == "" and emailData.title ~= "" then |
| 57 | 57 | title = emailData.title |
| ... | ... | @@ -67,12 +67,14 @@ function Email:data() |
| 67 | 67 | end |
| 68 | 68 | |
| 69 | 69 | return { |
| 70 | + cfgId = emailId, | |
| 70 | 71 | id = self:getProperty("id"), |
| 71 | 72 | status = self:getProperty("status"), |
| 72 | 73 | createtime = self:getProperty("createtime"), |
| 73 | 74 | title = title, |
| 74 | 75 | stitle = stitle, |
| 75 | 76 | content = content, |
| 77 | + contentPms = contentPms, | |
| 76 | 78 | attachments = attachments, |
| 77 | 79 | } |
| 78 | 80 | end | ... | ... |
src/models/RoleLog.lua
| ... | ... | @@ -42,6 +42,9 @@ local ItemReason = { |
| 42 | 42 | freeGift = 127, -- 免费礼包 |
| 43 | 43 | exploreCommand = 128, -- 探索指令 |
| 44 | 44 | drawHeroExtraReward = 129, -- 抽卡阶段奖励 |
| 45 | + actRecycle = 130, -- 活动道具回收 | |
| 46 | + actExchange = 131, -- 兑换活动 | |
| 47 | + actGachakon = 132, -- 扭蛋活动 | |
| 45 | 48 | |
| 46 | 49 | |
| 47 | 50 | advHang = 301, -- 拾荒挂机 | ... | ... |