Commit de111972fce375efd99425b889577284b209f1e6
Merge branch 'tr/bugfix-qa' into tr/bugfix
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({ | ... | ... |