Commit 96ca7852d4bdd947939c3d04845f5cda0d0306ec
1 parent
848695d1
钻石兑换招募券计算虹光玉数量bug
Showing
1 changed file
with
14 additions
and
5 deletions
Show diff stats
src/actions/RoleAction.lua
@@ -1407,20 +1407,29 @@ function _M.diamondConvertRpc(agent, data) | @@ -1407,20 +1407,29 @@ function _M.diamondConvertRpc(agent, data) | ||
1407 | if role:getAllDiamond() < cost then return 2 end | 1407 | if role:getAllDiamond() < cost then return 2 end |
1408 | 1408 | ||
1409 | local get = globalCsv.legal_tender_cost * cost | 1409 | local get = globalCsv.legal_tender_cost * cost |
1410 | - role:costDiamond({count = cost, log = {desc = "convert", int1 = ItemId.Jade, int2 = get}}) | 1410 | + role:costDiamond({count = cost, log = {desc = "convert", int1 = oper, int2 = get}}) |
1411 | local reward, change | 1411 | local reward, change |
1412 | if oper == 1 then -- 钻石兑换成虹光玉 | 1412 | if oper == 1 then -- 钻石兑换成虹光玉 |
1413 | reward, change = role:award({[ItemId.Jade] = get}, {log = {desc = "convert"}}) | 1413 | reward, change = role:award({[ItemId.Jade] = get}, {log = {desc = "convert"}}) |
1414 | elseif oper == 2 then -- 钻石兑换成虹光玉再兑换成招募券 | 1414 | elseif oper == 2 then -- 钻石兑换成虹光玉再兑换成招募券 |
1415 | - local allReward = {[ItemId.Jade] = get} | 1415 | + local old = role:getItemCount(ItemId.Jade) |
1416 | + get = old + get | ||
1417 | + | ||
1416 | local quan = math.floor(get/globalCsv.recruit_cost) | 1418 | local quan = math.floor(get/globalCsv.recruit_cost) |
1417 | - allReward[ItemId.Jade] = allReward[ItemId.Jade] - quan * globalCsv.recruit_cost | ||
1418 | - if allReward[ItemId.Jade] == 0 then | ||
1419 | - allReward[ItemId.Jade] = nil | 1419 | + local remain = get - quan * globalCsv.recruit_cost |
1420 | + | ||
1421 | + local allReward = {} | ||
1422 | + if remain > old then | ||
1423 | + allReward[ItemId.Jade] = remain - old | ||
1424 | + elseif remain == old then | ||
1425 | + else | ||
1426 | + role:costItems({[ItemId.Jade] = old - remain}, {log = {desc = "convert"}}) | ||
1420 | end | 1427 | end |
1428 | + | ||
1421 | if quan > 0 then | 1429 | if quan > 0 then |
1422 | allReward[ItemId.RecruitmentCard] = quan | 1430 | allReward[ItemId.RecruitmentCard] = quan |
1423 | end | 1431 | end |
1432 | + | ||
1424 | reward, change = role:award(allReward, {log = {desc = "convert"}}) | 1433 | reward, change = role:award(allReward, {log = {desc = "convert"}}) |
1425 | end | 1434 | end |
1426 | 1435 |