From 847f9a7b1e3f63a31d92dd8ea964ea0ece978206 Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Thu, 3 Dec 2020 11:51:30 +0800 Subject: [PATCH] 兑换活动,邮件内容修改 --- src/GlobalVar.lua | 1 + src/ProtocolCode.lua | 2 ++ src/actions/ActivityAction.lua | 32 ++++++++++++++++++++++++++++++++ src/actions/GmAction.lua | 3 ++- src/actions/RoleAction.lua | 11 +++++++++++ src/csvdata | 2 +- src/models/Activity.lua | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/models/Email.lua | 10 ++++++---- src/models/RoleLog.lua | 3 +++ 9 files changed, 121 insertions(+), 8 deletions(-) diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index b60de70..9e90d1c 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -304,6 +304,7 @@ MailId = { ActDrawCardReward = 222, ActAdvDrawReward = 223, ActOpenBoxReward = 224, + ActItemRecycle = 225, PaySignAward = 241, PayBackAward = 242, diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 5933add..9da72f8 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -50,6 +50,7 @@ actionCodes = { Role_useSelectItemRpc = 134, -- 使用多选一礼包 Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 Role_renameTeamRpc = 136, -- 编队改名 + Role_accuseRpc = 137, -- 举报 Adv_startAdvRpc = 151, Adv_startHangRpc = 152, @@ -217,6 +218,7 @@ actionCodes = { Activity_actPaySignRewardNtf = 654, Activity_actCalendaTaskRpc = 655, Activity_actPaySignRpc = 656, + Activity_exchangeRpc = 657, Radio_startQuestRpc = 700, Radio_finishQuestRpc = 701, diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index 2e88101..c265ef1 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -263,4 +263,36 @@ function _M.actCalendaTaskRpc(agent, data) return true end +function _M.exchangeRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local actid = msg.actid + local id = msg.id + if not role.activity:isOpen("Exchange") then return 1 end + + 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] + if curCount >= actCfg then return 4 end + + 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 + return _M \ No newline at end of file diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index fa94cf5..85d655f 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -533,7 +533,8 @@ function _M.test(role, pms) local id = tonum(pms.pm1, 0) --local hero = require ("actions.HeroAction") --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) - print(role:getPaybackReward(0, 10000)) + + role:sendMail(13, nil, "1=2", {111}) return "成功" end diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 2d4d0bc..14731a4 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -1279,4 +1279,15 @@ function _M.renameTeamRpc(agent, data) return true end +function _M.accuseRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local targetId = msg.targetId + local atype = msg.type + local note = msg.note + + role:mylog("role_action", {desc = "accuse", int1 = targetId, short1 = atype, text1 = note}) + return true +end + return _M \ No newline at end of file diff --git a/src/csvdata b/src/csvdata index 533ae01..7ddcf85 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 533ae0113773f4672ce8a4b01d911ed1f88a7d46 +Subproject commit 7ddcf852c731685bc3aa13e4f0bf7d7a86b45b65 diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 0e5816c..bc3afd1 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -19,6 +19,11 @@ Activity.ActivityType = { AdvDraw = 13, --拾荒抽周 资助 OpenBox = 14, --拆解周 时钟箱 RaceDraw = 16, -- 定向招募活动 + + ChallengeLevel = 17, -- 挑战关卡活动 + Exchange = 18, -- 兑换活动 + HangDrop = 19, -- 挂机掉落活动 + Gachakon = 20, -- 扭蛋活动 } @@ -48,6 +53,11 @@ Activity.schema = { act12 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励 act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 + + act20 = {"table", {}, true}, -- {id=兑换数量} + act21 = {"table", {}}, -- {id=抽取的数量} + act22 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} + act23 = {"table", {}}, -- {挂机信息} } function Activity:data() @@ -409,12 +419,34 @@ activityFunc[Activity.ActivityType.CalendaTask] = { -- end, } +-- 兑换 +activityFunc[Activity.ActivityType.Exchange] = { + ["init"] = function(self, actType, isCrossDay, notify, actId) + local role = self.owner + local actData = self:getActData(actType) or {} + actData[actId] = {} + self:updateActData(actType, actData, not notify) + end, + --["close"] = function(self, actType, notify, actId) + --end, +} + +-- 扭蛋机 +activityFunc[Activity.ActivityType.Gachakon] = { + ["init"] = function(self, actType, isCrossDay, notify, actId) + self:updateActData(actType, {}, not notify) + end, + ["crossDay"] = function(self, actType, notify) + self:updateActData(actType, {}, not notify) + end, +} + function Activity:initActivity(actId, isCrossDay, notify) local actData = csvdb["activity_ctrlCsv"][actId] if not actData then return end local actType = actData.showType if activityFunc[actType] and activityFunc[actType]['close'] then - activityFunc[actType]["init"](self, actType, isCrossDay, notify) + activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId) end end @@ -423,7 +455,8 @@ function Activity:closeActivity(actId, notify, notUpdateAct) if not actData then return end local actType = actData.showType if activityFunc[actType] and activityFunc[actType]['close'] then - activityFunc[actType]["close"](self, actType, notify) + activityFunc[actType]["close"](self, actType, notify, actId) + self:recycleActItem(actId) end if Activity.schema["act".. actType] then self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) @@ -529,5 +562,33 @@ function Activity:getPaySignReward() --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change))) end +-- 回收活动道具 +function Activity:recycleActItem(actId) + local role = self.owner + local actCfg = csvdb["activity_ctrlCsv"][actId] + if not actCfg then return end + local gift = {} + local costs = {} + for _, arr in ipairs(role:getItemCount(actCfg.recycle):toTableArray(true)) do + 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 + gift[toId] = toNum * itemCount + 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 + return Activity diff --git a/src/models/Email.lua b/src/models/Email.lua index 56b4a88..95ab75c 100644 --- a/src/models/Email.lua +++ b/src/models/Email.lua @@ -48,10 +48,10 @@ function Email:data() if emailData then -- 如果内容是直接插入到数据库 - if content == "" and emailData.body ~= "" then - content = io.readfile("src/" .. emailData.body) or "" - content = content:format(table.unpack(contentPms)) - end + --if content == "" and emailData.body ~= "" then + -- content = io.readfile("src/" .. emailData.body) or "" + -- content = content:format(table.unpack(contentPms)) + --end if title == "" and emailData.title ~= "" then title = emailData.title @@ -67,12 +67,14 @@ function Email:data() end return { + cfgId = emailId, id = self:getProperty("id"), status = self:getProperty("status"), createtime = self:getProperty("createtime"), title = title, stitle = stitle, content = content, + contentPms = contentPms, attachments = attachments, } end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index a2397ef..17bbec1 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -42,6 +42,9 @@ local ItemReason = { freeGift = 127, -- 免费礼包 exploreCommand = 128, -- 探索指令 drawHeroExtraReward = 129, -- 抽卡阶段奖励 + actRecycle = 130, -- 活动道具回收 + actExchange = 131, -- 兑换活动 + actGachakon = 132, -- 扭蛋活动 advHang = 301, -- 拾荒挂机 -- libgit2 0.21.2