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