From 4122c3bd483187718a0373d1b98e2965a435b61e Mon Sep 17 00:00:00 2001 From: chenyueqi Date: Thu, 28 Jan 2021 13:56:25 +0800 Subject: [PATCH] 进入中继层补给药剂,补足到上限,扣除错误 --- src/adv/Adv.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 2b587ff..9f76419 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -1127,10 +1127,17 @@ function Adv:supplyPotion() for potionId, set in pairs(potionCsv) do local count = potionBag[potionId] or 0 if count > 0 then - local level = dishTree:getv(potionId,1) - local num = math.min(set[level].limit,count) - advItems = advItems:setv(potionId,num) - potionBag[potionId] = num ~= count and (count - num) or nil + local max = set[dishTree:getv(potionId,1)].limit + local old = advItems:getv(potionId,0) + local need = max - old + + if need < count then + advItems = advItems:setv(potionId,max) + potionBag[potionId] = count - need + else + advItems = advItems:setv(potionId,old + count) + potionBag[potionId] = nil + end end end self.owner:updateProperties({ -- libgit2 0.21.2