From fe29684994d7de3c6389d8c0d2a8848589783110 Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Wed, 25 Nov 2020 21:03:19 +0800 Subject: [PATCH] 归还消耗指定道具或钻石 --- src/actions/HeroAction.lua | 29 +++++++++++++++++++++++------ src/csvdata | 2 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index df032e0..eaf70cd 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -604,7 +604,6 @@ end function _M.getResetRewardRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) - local pay = msg.pay local hero = role.heros[msg.id] if not hero then return end @@ -617,12 +616,30 @@ function _M.getResetRewardRpc(agent, data) local tmpLevel = level if level <= 1 and talent == "" then return end + local pay = true if level <= 60 then pay = false end - if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then - return 1 + if pay then + local costArr = globalCsv.unit_heroBack_cost:toArray(true, "=") + local itemCount = role:getItemCount(costArr[1]) + local totalCost = {} + if itemCount >= costArr[2] then + totalCost[costArr[1]] = costArr[2] + else + local diamond = (costArr[2] - itemCount) * costArr[3] + if role:getItemCount(ItemId.Diamond) < diamond then + return 1 + end + totalCost[costArr[1]] = itemCount + totalCost[ItemId.Diamond] = diamond + end + + --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then + -- return 1 + --end + role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}}) end local reward = {} @@ -677,10 +694,10 @@ function _M.getResetRewardRpc(agent, data) }) hero:mylog({desc = "resetHero"}) - local coef = globalCsv.unit_back_discount - coef = (pay or tmpLevel <= 60) and 1 or coef + --local coef = globalCsv.unit_back_discount + --coef = (pay or tmpLevel <= 60) and 1 or coef for itemId, count in pairs(reward) do - reward[itemId] = math.floor(count * coef) + reward[itemId] = count end local change reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) diff --git a/src/csvdata b/src/csvdata index a259823..533ae01 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit a2598231ccc5e16da1a27f976602871f30fcd035 +Subproject commit 533ae0113773f4672ce8a4b01d911ed1f88a7d46 -- libgit2 0.21.2