Commit a93ce9c0bf887ecb35493fcc2353cb58e6cbb365

Authored by zhangqijia
1 parent 8c154e11

fix: 特殊道具兑换, 增加活动判断,活动过期则返回错误码

Showing 1 changed file with 22 additions and 12 deletions   Show diff stats
src/actions/RoleAction.lua
... ... @@ -1716,31 +1716,41 @@ function _M.itemConvertSpecialRpc(agent, data)
1716 1716 local role = agent.role
1717 1717 local msg = MsgPack.unpack(data)
1718 1718 local itemId = msg.item_id
1719   - local count = msg.count or 1
1720   - local exchangeId = msg.exchange_id
  1719 + local exchangeId = tonumber(msg.exchange_id)
1721 1720  
1722 1721 local itemData = csvdb["itemCsv"][itemId]
1723 1722 if not itemData then return 1 end
1724 1723  
1725   - if not role:checkItemEnough({[itemId] = count}) then return 2 end
1726   - role:costItems({[itemId] = count}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}})
1727   -
1728 1724 local rechargeData = csvdb["shop_rechargeCsv"][exchangeId]
1729 1725 if not rechargeData then
1730 1726 skynet.error("[recharge] recharge id not exist", exchangeId)
1731   - return 3
  1727 + return 2
1732 1728 end
1733   - local reward = {}
1734   - for i = 1, count do
1735   - local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.id , rechargeData.activity_id)
  1729 +
  1730 + if not role:checkItemEnough({[itemId] = 1}) then return 3 end
  1731 +
  1732 + local reward = {}
  1733 + if rechargeData.type == CardType.ActBattleCommandCard then
  1734 + if role.activity:isOpenById(rechargeData.activity_id, "ActShopGoods") then
  1735 + local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id)
  1736 + if tmpreward then
  1737 + table.rewardMerge(reward, tmpreward)
  1738 + end
  1739 + else
  1740 + skynet.error("not open id: ".. rechargeData.id .. "; actid: " .. rechargeData.activity_id)
  1741 + SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack({result = 4}))
  1742 + return true
  1743 + end
  1744 + else
  1745 + local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id)
1736 1746 if tmpreward then
1737 1747 table.rewardMerge(reward, tmpreward)
1738   - else
1739   - return
1740 1748 end
1741 1749 end
1742 1750  
1743   - SendPacket(actionCodes.Role_itemConvertMonthCardRpc, MsgPack.pack(role:packReward(reward)))
  1751 + role:costItems({[itemId] = 1}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}})
  1752 +
  1753 + SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack(role:packReward(reward)))
1744 1754 return true
1745 1755 end
1746 1756  
... ...