fix effects birth

This commit is contained in:
neckrat 2026-05-01 01:21:53 +03:00
parent 5bc51c976e
commit efe98e8210

View File

@ -25,27 +25,35 @@ end
--- проверяет, можно ли наложить эффект и при наложении его применяет
--- @param effect EffectTag
--- @param stacks integer
--- @param intensity integer
function behavior:addEffect(effect, stacks, intensity)
local task1, birthStatement = book[effect]:beforeBirth(self.owner, intensity)
if task1 then
task1(function() end)
end
if not birthStatement then return end
-- проверяем эффект на возможности суммирования (aka противоречия)
for i, ef in ipairs(self.effectsPriority) do
if ef == effect then
self.effectsProperties[ef] = {
stacks = stacks + self.effectsProperties[ef].stacks,
intensity = intensity
}
local task2 = book[effect]:afterBirth(self.owner, intensity)
if task2 then
task2(function() 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
return
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
if efb.sums[effect] then
if efb.sums[effect][ef] then
if not efb.sums[effect][ef](self.owner, effect, ef) then return end