refact
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-02-22 18:15:24 +01:00
parent d9febf16e0
commit 83e2000198
10 changed files with 166 additions and 104 deletions

View File

@@ -48,6 +48,8 @@ local initialized_game = false
local function init_game()
if initialized_game then return end
reset_context_to_initial_state() -- Call it here
MenuWindow.refresh_menu_items()
initialized_game = true
end

View File

@@ -12,10 +12,26 @@ end
--- Navigates to a screen by its ID.
-- @param screen_id string The ID of the screen to go to.
function Util.go_to_screen_by_id(screen_id)
local screen_index = Context.screen_indices_by_id[screen_id]
if screen_index then
Context.current_screen = screen_index
Context.selected_decision_index = 1 else
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found or not indexed!"})
local screen = Screen.get_by_id(screen_id)
if screen then
Context.game.current_screen = screen_id
local all_decisions_for_screen = Decision.get_for_screen(screen)
Context.game.decisions = Decision.filter_available(all_decisions_for_screen)
Context.game.selected_decision_index = 1
screen.init() -- Initialize the new screen
else
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found!"})
end
end
-- Checks if a table contains a specific value.
-- @param t table The table to check.
-- @param value any The value to look for.
function Util.contains(t, value)
for i = 1, #t do
if t[i] == value then
return true
end
end
return false
end