Commit 4122c3bd483187718a0373d1b98e2965a435b61e

Authored by chenyueqi
1 parent a5a2c706

进入中继层补给药剂,补足到上限,扣除错误

Showing 1 changed file with 11 additions and 4 deletions   Show diff stats
src/adv/Adv.lua
... ... @@ -1127,10 +1127,17 @@ function Adv:supplyPotion()
1127 1127 for potionId, set in pairs(potionCsv) do
1128 1128 local count = potionBag[potionId] or 0
1129 1129 if count > 0 then
1130   - local level = dishTree:getv(potionId,1)
1131   - local num = math.min(set[level].limit,count)
1132   - advItems = advItems:setv(potionId,num)
1133   - potionBag[potionId] = num ~= count and (count - num) or nil
  1130 + local max = set[dishTree:getv(potionId,1)].limit
  1131 + local old = advItems:getv(potionId,0)
  1132 + local need = max - old
  1133 +
  1134 + if need < count then
  1135 + advItems = advItems:setv(potionId,max)
  1136 + potionBag[potionId] = count - need
  1137 + else
  1138 + advItems = advItems:setv(potionId,old + count)
  1139 + potionBag[potionId] = nil
  1140 + end
1134 1141 end
1135 1142 end
1136 1143 self.owner:updateProperties({
... ...