Commit fe29684994d7de3c6389d8c0d2a8848589783110

Authored by 测试
1 parent d93ec42c

归还消耗指定道具或钻石

Showing 2 changed files with 24 additions and 7 deletions   Show diff stats
src/actions/HeroAction.lua
@@ -604,7 +604,6 @@ end @@ -604,7 +604,6 @@ end
604 function _M.getResetRewardRpc(agent, data) 604 function _M.getResetRewardRpc(agent, data)
605 local role = agent.role 605 local role = agent.role
606 local msg = MsgPack.unpack(data) 606 local msg = MsgPack.unpack(data)
607 - local pay = msg.pay  
608 607
609 local hero = role.heros[msg.id] 608 local hero = role.heros[msg.id]
610 if not hero then return end 609 if not hero then return end
@@ -617,12 +616,30 @@ function _M.getResetRewardRpc(agent, data) @@ -617,12 +616,30 @@ function _M.getResetRewardRpc(agent, data)
617 local tmpLevel = level 616 local tmpLevel = level
618 if level <= 1 and talent == "" then return end 617 if level <= 1 and talent == "" then return end
619 618
  619 + local pay = true
620 if level <= 60 then 620 if level <= 60 then
621 pay = false 621 pay = false
622 end 622 end
623 623
624 - if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then  
625 - return 1 624 + if pay then
  625 + local costArr = globalCsv.unit_heroBack_cost:toArray(true, "=")
  626 + local itemCount = role:getItemCount(costArr[1])
  627 + local totalCost = {}
  628 + if itemCount >= costArr[2] then
  629 + totalCost[costArr[1]] = costArr[2]
  630 + else
  631 + local diamond = (costArr[2] - itemCount) * costArr[3]
  632 + if role:getItemCount(ItemId.Diamond) < diamond then
  633 + return 1
  634 + end
  635 + totalCost[costArr[1]] = itemCount
  636 + totalCost[ItemId.Diamond] = diamond
  637 + end
  638 +
  639 + --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then
  640 + -- return 1
  641 + --end
  642 + role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}})
626 end 643 end
627 644
628 local reward = {} 645 local reward = {}
@@ -677,10 +694,10 @@ function _M.getResetRewardRpc(agent, data) @@ -677,10 +694,10 @@ function _M.getResetRewardRpc(agent, data)
677 }) 694 })
678 hero:mylog({desc = "resetHero"}) 695 hero:mylog({desc = "resetHero"})
679 696
680 - local coef = globalCsv.unit_back_discount  
681 - coef = (pay or tmpLevel <= 60) and 1 or coef 697 + --local coef = globalCsv.unit_back_discount
  698 + --coef = (pay or tmpLevel <= 60) and 1 or coef
682 for itemId, count in pairs(reward) do 699 for itemId, count in pairs(reward) do
683 - reward[itemId] = math.floor(count * coef) 700 + reward[itemId] = count
684 end 701 end
685 local change 702 local change
686 reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) 703 reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
1 -Subproject commit a2598231ccc5e16da1a27f976602871f30fcd035 1 +Subproject commit 533ae0113773f4672ce8a4b01d911ed1f88a7d46