refact
This commit is contained in:
@@ -2,6 +2,7 @@ Decision.register({
|
||||
id = "have_a_coffee",
|
||||
label = "Have a Coffee",
|
||||
handle = function()
|
||||
Situation.apply("drink_coffee")
|
||||
local new_situation_id = Situation.apply("drink_coffee", Context.game.current_screen)
|
||||
Context.game.current_situation = new_situation_id
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -33,6 +33,37 @@ end
|
||||
|
||||
--- Gets all registered decisions.
|
||||
-- @return table A table of all registered decisions.
|
||||
function Decision.get_all()
|
||||
function Decision.get_all_registered()
|
||||
return _decisions
|
||||
end
|
||||
|
||||
--- Gets decision objects based on a screen's data.
|
||||
-- @param screen_data table The data for the screen, containing a 'decisions' field (list of decision IDs).
|
||||
-- @return table A table containing decision objects relevant to the screen.
|
||||
function Decision.get_for_screen(screen_data)
|
||||
if not screen_data or not screen_data.decisions then
|
||||
return {}
|
||||
end
|
||||
|
||||
local screen_decisions = {}
|
||||
for _, decision_id in ipairs(screen_data.decisions) do
|
||||
local decision = Decision.get(decision_id)
|
||||
if decision then
|
||||
table.insert(screen_decisions, decision)
|
||||
end
|
||||
end
|
||||
return screen_decisions
|
||||
end
|
||||
|
||||
--- Filters a list of decision objects based on their condition function.
|
||||
-- @param decisions_list table A table of decision objects.
|
||||
-- @return table A new table containing only the decisions for which condition() is true.
|
||||
function Decision.filter_available(decisions_list)
|
||||
local available = {}
|
||||
for _, decision in ipairs(decisions_list) do
|
||||
if decision and decision.condition() then
|
||||
table.insert(available, decision)
|
||||
end
|
||||
end
|
||||
return available
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Decision.register({
|
||||
id = "play_button_mash",
|
||||
label = "Play Button Mash",
|
||||
handle = function() Meter.hide() MinigameButtonMashWindow.start(WINDOW_GAME) end,
|
||||
handle = function() Meter.hide() MinigameButtonMashWindow.start("game") end,
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Decision.register({
|
||||
id = "play_ddr",
|
||||
label = "Play DDR (Random)",
|
||||
handle = function() Meter.hide() MinigameDDRWindow.start(WINDOW_GAME, nil) end,
|
||||
handle = function() Meter.hide() MinigameDDRWindow.start("game", nil) end,
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Decision.register({
|
||||
id = "play_rhythm",
|
||||
label = "Play Rhythm Game",
|
||||
handle = function() Meter.hide() MinigameRhythmWindow.start(WINDOW_GAME) end,
|
||||
handle = function() Meter.hide() MinigameRhythmWindow.start("game") end,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user