From 96ca7852d4bdd947939c3d04845f5cda0d0306ec Mon Sep 17 00:00:00 2001 From: chenyueqi Date: Wed, 31 Mar 2021 10:04:35 +0800 Subject: [PATCH] 钻石兑换招募券计算虹光玉数量bug --- src/actions/RoleAction.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index cace97a..a635fab 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -1407,20 +1407,29 @@ function _M.diamondConvertRpc(agent, data) if role:getAllDiamond() < cost then return 2 end local get = globalCsv.legal_tender_cost * cost - role:costDiamond({count = cost, log = {desc = "convert", int1 = ItemId.Jade, int2 = get}}) + role:costDiamond({count = cost, log = {desc = "convert", int1 = oper, int2 = get}}) local reward, change if oper == 1 then -- 钻石兑换成虹光玉 reward, change = role:award({[ItemId.Jade] = get}, {log = {desc = "convert"}}) elseif oper == 2 then -- 钻石兑换成虹光玉再兑换成招募券 - local allReward = {[ItemId.Jade] = get} + local old = role:getItemCount(ItemId.Jade) + get = old + get + local quan = math.floor(get/globalCsv.recruit_cost) - allReward[ItemId.Jade] = allReward[ItemId.Jade] - quan * globalCsv.recruit_cost - if allReward[ItemId.Jade] == 0 then - allReward[ItemId.Jade] = nil + local remain = get - quan * globalCsv.recruit_cost + + local allReward = {} + if remain > old then + allReward[ItemId.Jade] = remain - old + elseif remain == old then + else + role:costItems({[ItemId.Jade] = old - remain}, {log = {desc = "convert"}}) end + if quan > 0 then allReward[ItemId.RecruitmentCard] = quan end + reward, change = role:award(allReward, {log = {desc = "convert"}}) end -- libgit2 0.21.2