Commit a2f11550d0e67b4464edcdbe636aa3eaf67b759f

Authored by zhouhaihai
1 parent e63957d5

完善道具转换

(cherry picked from commit a7b69ec296f42f49a6cc6e6b1d7c715af2bb34f5)
Showing 1 changed file with 21 additions and 13 deletions   Show diff stats
src/models/RolePlugin.lua
... ... @@ -67,9 +67,16 @@ function RolePlugin.bind(Role)
67 67 local itemTypeAward = {
68 68 [ItemType.Hero] = function()
69 69 pms.type = itemId - ItemStartId.Hero
70   - for _= 1, count do
71   - self:addHero(pms)
  70 + local status = self:addHero(pms)
  71 + local gcount = 1
  72 + if not status then
  73 + gcount = 0
  74 + end
  75 + if count - gcount > 0 then
  76 + local heroData = csvdb["unitCsv"][pms.type]
  77 + change[pms.type] = (change[pms.type] or 0) + (count - gcount) * globalCsv.draw_unit_tofragment[heroData.rare]
72 78 end
  79 + count = gcount
73 80 end,
74 81 [ItemType.EquipBase] = function()
75 82 local typ = math.floor((itemId-7000)/100)
... ... @@ -105,7 +112,7 @@ function RolePlugin.bind(Role)
105 112 end
106 113 end
107 114  
108   - return count, change -- count 刷新实际发放的奖励个数 change 物品实际奖励与当前id 不符 就发生转换 而不实际发奖
  115 + return count, change -- count 实际发放的奖励个数 change 物品实际奖励与当前id 不符 就发生转换 而不实际发奖
109 116 end
110 117  
111 118  
... ... @@ -122,17 +129,18 @@ function RolePlugin.bind(Role)
122 129 end
123 130 local reward, allChange = {}, {}
124 131  
125   - for itemId, count in pairs(tgift) do
126   - local count, change = _award(self, itemId, count, params)
  132 + for itemId, rcount in pairs(tgift) do
  133 + local count, change = _award(self, itemId, rcount, params)
  134 + if count > 0 then
  135 + reward[itemId] = (reward[itemId] or 0) + count
  136 + end
127 137 if next(change) then
128   - local cr, cc = self:award(change, params) -- 内部转换忽略
129   - for _id, _ct in pairs(cr) do
130   - reward[_id] = (reward[_id] or 0) + _ct
131   - end
132   - table.insert(allChange, {form = {[itemId] = count}, to = cr})
133   - else
134   - if count > 0 then
135   - reward[itemId] = (reward[itemId] or 0) + count
  138 + local cr, _ = self:award(change, params) -- 内部转换忽略 防止死循环
  139 + if next(cr) then
  140 + for _id, _ct in pairs(cr) do
  141 + reward[_id] = (reward[_id] or 0) + _ct
  142 + end
  143 + table.insert(allChange, {form = {[itemId] = rcount - count}, to = cr})
136 144 end
137 145 end
138 146 end
... ...