30 lines
875 B
Lua
30 lines
875 B
Lua
--- @alias ImpactType "physic"|"magic"
|
|
|
|
--- Представляет из себя некое "взаимодействие", которое мы должны применить к игроку в зависимости от контекста,
|
|
--- например, нанести урон.
|
|
--- @class Impact
|
|
--- @field intensity integer
|
|
--- @field impactType ImpactType
|
|
local impact = {}
|
|
impact.__index = impact
|
|
|
|
--- @param other Impact
|
|
function impact:__add(other)
|
|
self.intensity = self.intensity + other.intensity
|
|
return self
|
|
end
|
|
|
|
--- @param other Impact
|
|
function impact:__sub(other)
|
|
self.intensity = self.intensity - other.intensity
|
|
return self
|
|
end
|
|
|
|
--- @param intensity integer
|
|
--- @param impactType ImpactType
|
|
local function new(intensity, impactType)
|
|
return setmetatable({ intensity = intensity, impactType = impactType }, impact)
|
|
end
|
|
|
|
return new
|