From d51114bda792fceb51bf57ff74eb206159691718 Mon Sep 17 00:00:00 2001 From: wangyujie <690681240@qq.com> Date: Wed, 8 Jul 2020 10:51:02 +0800 Subject: [PATCH] 完成需求:每日金币购买 --- src/ProtocolCode.lua | 1 + src/actions/RoleAction.lua | 28 ++++++++++++++++++++++++++++ src/models/Daily.lua | 4 +++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 038b218..c137a00 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -42,6 +42,7 @@ actionCodes = { Role_openSpeedUpBoxRpc = 128, Role_guideRpc = 129, Role_getRandomNameRpc = 130, + Role_goldBuyRpc = 131, Adv_startAdvRpc = 151, Adv_startHangRpc = 152, diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 9a6bd84..61ef0bc 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -1005,4 +1005,32 @@ function _M.guideRpc(agent, data) return true end +function _M.goldBuyRpc(agent, data) + local role = agent.role + local curT = role.dailyData:getProperty("goldBuyT") + local costD = globalCsv.idle_quickMoney_cost[curT] + if not costD then + return 1 + end + if costD ~= 0 and not role:checkItemEnough({[ItemId.Diamond] = costD}) then + return 2 + end + local goldC = 0 + local hangPass = role:getProperty("hangPass") + for i = 1, 3 do + if hangPass[i] then + local carbonData = csvdb["idle_battleCsv"][hangPass[i]] + goldC = math.max(goldC, carbonData.money * globalCsv.idle_quickMoney_effect) + end + end + if goldC == 0 then + return 3 + end + role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) + role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}}) + local reward = role:award({[ItemId.Gold] = goldC}, {log = {desc = "goldBuy"}}) + SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack({reward = reward})) + return true +end + return _M \ No newline at end of file diff --git a/src/models/Daily.lua b/src/models/Daily.lua index cf5667b..a8d129f 100644 --- a/src/models/Daily.lua +++ b/src/models/Daily.lua @@ -24,7 +24,8 @@ Daily.schema = { dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计 dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计 - advSupRe = {"number", 0}, -- 冒险支援效果刷新次数 + advSupRe = {"number", 0}, -- 冒险支援效果刷新次数 + goldBuyT = {"number", 0}, -- 金币购买次数 } function Daily:updateProperty(params) @@ -97,6 +98,7 @@ function Daily:data() dailySDC = self:getProperty("dailySDC"), dailySDD = self:getProperty("dailySDD"), advSupRe = self:getProperty("advSupRe"), + goldBuyT = self:getProperty("goldBuyT"), } end -- libgit2 0.21.2