From b75dca12cb9ac2b0772f35ddd8bef6ea5a84f47a Mon Sep 17 00:00:00 2001 From: neckrat Date: Fri, 1 May 2026 02:18:12 +0300 Subject: [PATCH] smol refactor effects:addEffect --- lib/character/behaviors/effects.lua | 32 ++++++++++------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/character/behaviors/effects.lua b/lib/character/behaviors/effects.lua index e11fa98..0c5e85c 100644 --- a/lib/character/behaviors/effects.lua +++ b/lib/character/behaviors/effects.lua @@ -32,25 +32,6 @@ function behavior:addEffect(effect, stacks, intensity) task1(function() end) end if not birthStatement then return end - -- проверяем на наличие того же эффекта - if self.effectsProperties[effect] then - -- добавляем в конец очереди эффектов - for i, ef in ipairs(self.effectsPriority) do - if ef == effect then - table.remove(self.effectsProperties, i) - self.effectsProperties[#self.effectsProperties + 1] = ef - end - end - self.effectsProperties[effect] = { - stacks = stacks, - intensity = intensity - } - local task2 = book[effect]:afterBirth(self.owner, intensity) - if task2 then - task2(function() end) - end - return - end -- проверка на сумму, и её применение for i, ef in ipairs(self.effectsPriority) do @@ -64,8 +45,17 @@ function behavior:addEffect(effect, stacks, intensity) end end end - - self.effectsPriority[#self.effectsPriority + 1] = effect + -- проверяем на наличие такого эффекта + if self.effectsProperties[effect] then + for i, ef in ipairs(self.effectsPriority) do + if ef == effect then + table.remove(self.effectsProperties, i) + self.effectsProperties[#self.effectsProperties + 1] = ef + end + end + else + self.effectsPriority[#self.effectsPriority + 1] = effect + end self.effectsProperties[effect] = { stacks = stacks, intensity = intensity