Commit a04fb7d7101ce9449d0e2f814744c0ce15203bca

Authored by liuzujun
2 parents e8f3af2a 96ca7852

Merge branch 'cn/develop-mysql' of 120.26.43.151:wasteland/server into cn/develop-mysql

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