added effect sum functional (its tough (in bad way))
This commit is contained in:
parent
d8a89ec24b
commit
53c83bf1a1
@ -1,4 +1,5 @@
|
|||||||
local task = require "lib.utils.task"
|
local task = require "lib.utils.task"
|
||||||
|
local efb = require "lib.effectbook"
|
||||||
|
|
||||||
--- ===========ЛОГИКА ЭФФЕКТОВ И ЧТО С ЭТИМ ЕДЯТ===========
|
--- ===========ЛОГИКА ЭФФЕКТОВ И ЧТО С ЭТИМ ЕДЯТ===========
|
||||||
--- читать здесь: https://docs.google.com/document/d/1Hxa5dOLaeRpLQOs5H-oIDDuLLhKbDw40lR9d62Zb4Tg/edit?usp=sharing
|
--- читать здесь: https://docs.google.com/document/d/1Hxa5dOLaeRpLQOs5H-oIDDuLLhKbDw40lR9d62Zb4Tg/edit?usp=sharing
|
||||||
@ -15,7 +16,6 @@ behavior.id = "effects"
|
|||||||
|
|
||||||
--- @return EffectsBehavior
|
--- @return EffectsBehavior
|
||||||
function behavior.new()
|
function behavior.new()
|
||||||
local efb = require "lib.effectbook"
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
effectbook = efb.of { efb.bleeding, efb.aversionToDeath },
|
effectbook = efb.of { efb.bleeding, efb.aversionToDeath },
|
||||||
effectsPriority = {},
|
effectsPriority = {},
|
||||||
@ -45,10 +45,12 @@ function behavior:addEffect(effect, stacks, intensity)
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local effectSum = effect:sum(ef)
|
|
||||||
if effectSum then
|
if effect.tag == ef.tag then break end
|
||||||
-- применяем результат суммы и удаляем эффект
|
for k, v in pairs(efb.sums) do
|
||||||
return
|
if k[effect.tag] and k[ef.tag] then
|
||||||
|
if not v(self.owner, effect, ef) then return end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ end
|
|||||||
function bleeding:afterTurn(owner, intensity)
|
function bleeding:afterTurn(owner, intensity)
|
||||||
local behavior = owner:has(Tree.behaviors.effects)
|
local behavior = owner:has(Tree.behaviors.effects)
|
||||||
if not behavior then
|
if not behavior then
|
||||||
print('[Effect]: yo man what the hell wheres your behavior how thats possible please stop thats not normal')
|
print('[EffectBook]: yo man what the hell wheres your behavior how thats possible please stop thats not normal')
|
||||||
else
|
else
|
||||||
behavior:deleteStacks(self, 1)
|
behavior:deleteStacks(self, 1)
|
||||||
end
|
end
|
||||||
@ -80,7 +80,26 @@ function aversionToDeath:beforeTurn(owner, intensity)
|
|||||||
}, false
|
}, false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Принимает таблицу, в ключах которых тэги эффектов, которые мы хотим просуммировать, и в значениях которых функция,
|
||||||
|
--- возвращающая применять ли эффект после суммирования.
|
||||||
|
---
|
||||||
|
--- В функции порядок эффектов, что передали в качестве аргумента, не определён.
|
||||||
|
--- @type table<table<string, boolean>, fun(owner: Character, effect1: Effect, effect2: Effect): boolean>
|
||||||
|
local sums = {}
|
||||||
|
sums[{ [bleeding.tag] = true, [aversionToDeath.tag] = true }] = function(owner, effect1, effect2)
|
||||||
|
print("[EffectBook]: применяем сумму, удаляем оба эффекта")
|
||||||
|
local behaviorEffect = owner:has(Tree.behaviors.effects)
|
||||||
|
if not behaviorEffect then
|
||||||
|
print("[EffectBook]: yo man what the hell wheres your behavior how thats possible please stop thats not normal")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
behaviorEffect:deleteEffect(effect1)
|
||||||
|
behaviorEffect:deleteEffect(effect2)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local effectbook = {
|
local effectbook = {
|
||||||
|
sums = sums,
|
||||||
bleeding = bleeding,
|
bleeding = bleeding,
|
||||||
aversionToDeath = aversionToDeath
|
aversionToDeath = aversionToDeath
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,9 +114,9 @@ function effect:beforeRegeneration(owner, intensity, amountHp) return taskUtils.
|
|||||||
--- @return Task<nil>
|
--- @return Task<nil>
|
||||||
function effect:afterRegeneration(owner, intensity) return taskUtils.wait {} end
|
function effect:afterRegeneration(owner, intensity) return taskUtils.wait {} end
|
||||||
|
|
||||||
--- @param other Effect
|
-- --- @param other Effect
|
||||||
--- @return Effect|nil
|
-- --- @return function
|
||||||
function effect:sum(other) end
|
-- function effect:sum(other) return function() end end
|
||||||
|
|
||||||
function effect:update(dt) end
|
function effect:update(dt) end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user