This commit is contained in:
31
inc/decision/decision.manager.lua
Normal file
31
inc/decision/decision.manager.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
local _decisions = {}
|
||||
|
||||
function DecisionManager.register(decision)
|
||||
if not decision or not decision.id then
|
||||
PopupWindow.show({"Error: Invalid decision object registered (missing id)!"})
|
||||
return
|
||||
end
|
||||
if not decision.label then
|
||||
PopupWindow.show({"Error: Invalid decision object registered (missing label)!"})
|
||||
return
|
||||
end
|
||||
|
||||
if not decision.condition then
|
||||
decision.condition = function() return true end
|
||||
end
|
||||
if not decision.handle then
|
||||
decision.handle = function() end
|
||||
end
|
||||
if _decisions[decision.id] then
|
||||
trace("Warning: Overwriting decision with id: " .. decision.id)
|
||||
end
|
||||
_decisions[decision.id] = decision
|
||||
end
|
||||
|
||||
function DecisionManager.get(id)
|
||||
return _decisions[id]
|
||||
end
|
||||
|
||||
function DecisionManager.get_all()
|
||||
return _decisions
|
||||
end
|
||||
Reference in New Issue
Block a user