some silly effect functions
This commit is contained in:
parent
aa4c5185d3
commit
9b10557435
@ -15,13 +15,37 @@ end
|
|||||||
|
|
||||||
--- проверяет, можно ли наложить эффект и при наложении его применяет
|
--- проверяет, можно ли наложить эффект и при наложении его применяет
|
||||||
--- @param effect Effect
|
--- @param effect Effect
|
||||||
function behavior:addEffect(effect)
|
--- @param cooldown integer
|
||||||
|
function behavior:addEffect(effect, cooldown)
|
||||||
|
-- проверяем эффект на возможности суммирования (aka противоречия)
|
||||||
|
for ef, t in pairs(self.effects) do
|
||||||
|
local effectSum = effect:sum(ef)
|
||||||
|
if effectSum then
|
||||||
|
-- применяем результат суммы и удаляем эффект
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- должен вызываться в конце хода;
|
self.effects[effect] = cooldown
|
||||||
function behavior:updateEffects()
|
effect:onBirth()
|
||||||
|
end
|
||||||
|
|
||||||
|
--- должен вызываться в начале хода
|
||||||
|
function behavior:onStartTurn()
|
||||||
|
for ef, t in pairs(self.effects) do
|
||||||
|
if t == 0 then
|
||||||
|
ef:onDeath()
|
||||||
|
self.effects[ef] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- должен вызываться в конце хода
|
||||||
|
function behavior:onEndTurn()
|
||||||
|
for ef, t in pairs(self.effects) do
|
||||||
|
self.effects[ef] = t - 1
|
||||||
|
ef:onEndTurn()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return behavior
|
return behavior
|
||||||
|
|||||||
@ -2,6 +2,28 @@
|
|||||||
local effect = {}
|
local effect = {}
|
||||||
effect.__index = effect
|
effect.__index = effect
|
||||||
|
|
||||||
|
function effect:onBirth()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function effect:onDeath()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function effect:onStartTurn()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function effect:onEndTurn()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @param other Effect
|
||||||
|
--- @return Effect|nil
|
||||||
|
function effect:sum(other)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function effect:update(dt)
|
function effect:update(dt)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -10,8 +32,9 @@ function effect:draw()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function effect.new()
|
--- @return Effect
|
||||||
|
local function new()
|
||||||
return setmetatable({}, effect)
|
return setmetatable({}, effect)
|
||||||
end
|
end
|
||||||
|
|
||||||
return effect
|
return { new = new }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user