From 6e1cf1db3ee8864b2c124e85a1ff3d0f8afb44af Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Thu, 2 Apr 2026 15:07:04 +0200 Subject: [PATCH] remove situation management --- .luacheckrc | 1 - impostor.inc | 3 - inc/decision/decision.have_a_coffee.lua | 16 ----- inc/init/init.context.lua | 3 +- inc/init/init.module.lua | 1 - inc/screen/screen.manager.lua | 6 -- inc/screen/screen.office.lua | 3 - inc/situation/situation.drink_coffee.lua | 6 -- inc/situation/situation.manager.lua | 84 ------------------------ inc/window/window.game.lua | 8 --- 10 files changed, 1 insertion(+), 130 deletions(-) delete mode 100644 inc/decision/decision.have_a_coffee.lua delete mode 100644 inc/situation/situation.drink_coffee.lua delete mode 100644 inc/situation/situation.manager.lua diff --git a/.luacheckrc b/.luacheckrc index 8f58d89..0c64bc2 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -10,7 +10,6 @@ globals = { "Discussion", "Util", "Decision", - "Situation", "Screen", "Sprite", "UI", diff --git a/impostor.inc b/impostor.inc index 7f39293..9d71029 100644 --- a/impostor.inc +++ b/impostor.inc @@ -38,10 +38,7 @@ sprite/sprite.matrix_architect.lua sprite/sprite.matrix_neo.lua sprite/sprite.matrix_oraculum.lua sprite/sprite.matrix_trinity.lua -situation/situation.manager.lua -situation/situation.drink_coffee.lua decision/decision.manager.lua -decision/decision.have_a_coffee.lua decision/decision.go_to_home.lua decision/decision.go_to_toilet.lua decision/decision.go_to_walking_to_office.lua diff --git a/inc/decision/decision.have_a_coffee.lua b/inc/decision/decision.have_a_coffee.lua deleted file mode 100644 index a7c5212..0000000 --- a/inc/decision/decision.have_a_coffee.lua +++ /dev/null @@ -1,16 +0,0 @@ -Decision.register({ - id = "have_a_coffee", - label = "Have a Coffee", - handle = function() - local new_situation_id = Situation.apply("drink_coffee", Context.game.current_screen) - local level = Ascension.get_level() - local disc_id = "coworker_disc_0" - -- TODO: Add more discussions for levels above 3 - if level >= 1 and level <= 3 then - local suffix = Context.have_done_work_today and ("_asc_" .. level) or ("_" .. level) - disc_id = "coworker_disc" .. suffix - end - Discussion.start(disc_id, "game") - Context.game.current_situation = new_situation_id - end, -}) \ No newline at end of file diff --git a/inc/init/init.context.lua b/inc/init/init.context.lua index a3d9100..728ab68 100644 --- a/inc/init/init.context.lua +++ b/inc/init/init.context.lua @@ -23,7 +23,7 @@ Context = {} --- * have_met_sumphore (boolean) Whether the player has talked to the homeless guy.
--- * have_been_to_office (boolean) Whether the player has been to the office.
--- * have_done_work_today (boolean) Whether the player has done work today.
---- * game (table) Current game progress state. Contains: `current_screen` (string) active screen ID, `current_situation` (string|nil) active situation ID.
+--- * game (table) Current game progress state. Contains: `current_screen` (string) active screen ID
function Context.initial_data() return { current_menu_item = 1, @@ -48,7 +48,6 @@ function Context.initial_data() have_met_sumphore = false, game = { current_screen = "home", - current_situation = nil, }, day_count = 1, delta_time = 0, diff --git a/inc/init/init.module.lua b/inc/init/init.module.lua index b5c6d56..ecdeb67 100644 --- a/inc/init/init.module.lua +++ b/inc/init/init.module.lua @@ -3,7 +3,6 @@ Util = {} Meter = {} Minigame = {} Decision = {} -Situation = {} Screen = {} Map = {} UI = {} diff --git a/inc/screen/screen.manager.lua b/inc/screen/screen.manager.lua index c56419a..9d3eb0a 100644 --- a/inc/screen/screen.manager.lua +++ b/inc/screen/screen.manager.lua @@ -8,7 +8,6 @@ local _screens = {} --- @param screen_data.name string Display name of the screen. --- @param screen_data.decisions table Array of decision ID strings available on this screen. --- @param screen_data.background string Map ID used as background. ---- @param[opt] screen_data.situations table Array of situation ID strings. Defaults to {}. --- @param[opt] screen_data.init function Called when the screen is entered. Defaults to noop. --- @param[opt] screen_data.update function Called each frame while screen is active. Defaults to noop. --- @param[opt] screen_data.draw function Called after the focus overlay to draw screen-specific overlays. Defaults to noop. @@ -16,9 +15,6 @@ function Screen.register(screen_data) if _screens[screen_data.id] then trace("Warning: Overwriting screen with id: " .. screen_data.id) end - if not screen_data.situations then - screen_data.situations = {} - end if not screen_data.init then screen_data.init = function() end end @@ -43,7 +39,6 @@ end --- * name (string) Display name.
--- * decisions (table) Array of decision ID strings.
--- * background (string) Map ID used as background.
---- * situations (table) Array of situation ID strings.
--- * init (function) Called when the screen is entered.
--- * update (function) Called each frame while screen is active. function Screen.get_by_id(screen_id) @@ -58,7 +53,6 @@ end --- * name (string) Display name of the screen.
--- * decisions (table) Array of decision ID strings available on this screen.
--- * background (string) Map ID used as background.
---- * situations (table) Array of situation ID strings.
--- * init (function) Called when the screen is entered.
--- * update (function) Called each frame while screen is active.
function Screen.get_all() diff --git a/inc/screen/screen.office.lua b/inc/screen/screen.office.lua index 917f953..8d8aa89 100644 --- a/inc/screen/screen.office.lua +++ b/inc/screen/screen.office.lua @@ -6,9 +6,6 @@ Screen.register({ "go_to_walking_to_home", "have_a_coffee", }, - situations = { - "drink_coffee", - }, init = function() Audio.music_play_room_work() end, diff --git a/inc/situation/situation.drink_coffee.lua b/inc/situation/situation.drink_coffee.lua deleted file mode 100644 index d791d0e..0000000 --- a/inc/situation/situation.drink_coffee.lua +++ /dev/null @@ -1,6 +0,0 @@ -Situation.register({ - id = "drink_coffee", - handle = function() - Audio.sfx_select() - end, -}) diff --git a/inc/situation/situation.manager.lua b/inc/situation/situation.manager.lua deleted file mode 100644 index 17d2e4e..0000000 --- a/inc/situation/situation.manager.lua +++ /dev/null @@ -1,84 +0,0 @@ ---- @section Situation -local _situations = {} - ---- Registers a situation definition. ---- @within Situation ---- @param situation table The situation data table. ---- @param situation.id string Unique situation identifier.
---- @param[opt] situation.screen_id string ID of the screen this situation belongs to.
---- @param[opt] situation.handle function Called when the situation is applied. Defaults to noop.
---- @param[opt] situation.update function Called each frame while situation is active. Defaults to noop.
-function Situation.register(situation) - if not situation or not situation.id then - PopupWindow.show({"Error: Invalid situation object registered (missing id)!"}) - return - end - if not situation.handle then - situation.handle = function() end - end - if not situation.update then - situation.update = function() end - end - if _situations[situation.id] then - trace("Warning: Overwriting situation with id: " .. situation.id) - end - _situations[situation.id] = situation -end - ---- Gets a situation by ID. ---- @within Situation ---- @param id string The situation ID. ---- @return result table The situation table or nil.
---- Fields:
---- * id (string) Unique situation identifier.
---- * screen_id (string) ID of the screen this situation belongs to.
---- * handle (function) Called when the situation is applied.
---- * update (function) Called each frame while situation is active.
-function Situation.get_by_id(id) - return _situations[id] -end - ---- Gets all registered situations, optionally filtered by screen ID. ---- @within Situation ---- @param screen_id string Optional. If provided, returns situations associated with this screen ID. ---- @return result table A table containing all registered situation data, indexed by their IDs, or an array filtered by screen_id.
---- Fields:
---- * id (string) Unique situation identifier.
---- * screen_id (string) ID of the screen this situation belongs to.
---- * handle (function) Called when the situation is applied.
---- * update (function) Called each frame while situation is active.
-function Situation.get_all(screen_id) - if screen_id then - local filtered_situations = {} - for _, situation in pairs(_situations) do - if situation.screen_id == screen_id then - table.insert(filtered_situations, situation) - end - end - return filtered_situations - end - return _situations -end - ---- Applies a situation, checking screen compatibility and returning the new situation ID if successful. ---- @within Situation ---- @param id string The situation ID to apply. ---- @param current_screen_id string The ID of the currently active screen. ---- @return string|nil The ID of the applied situation if successful, otherwise nil. -function Situation.apply(id, current_screen_id) - local situation = Situation.get_by_id(id) - local screen = Screen.get_by_id(current_screen_id) - - if not situation then - trace("Error: No situation found with id: " .. id) - return nil - end - - if Util.contains(screen.situations, id) then - situation.handle() - return id - else - trace("Info: Situation " .. id .. " cannot be applied to current screen (id: " .. current_screen_id .. ").") - return nil - end -end diff --git a/inc/window/window.game.lua b/inc/window/window.game.lua index d1862dd..3b3f06b 100644 --- a/inc/window/window.game.lua +++ b/inc/window/window.game.lua @@ -48,14 +48,6 @@ function GameWindow.update() if not screen or not screen.update then return end screen.update() - -- Handle current situation updates - if Context.game.current_situation then - local current_situation_obj = Situation.get_by_id(Context.game.current_situation) - if current_situation_obj and type(current_situation_obj.update) == "function" then - current_situation_obj.update() - end - end - if Context.stat_screen_active then return end -- Fetch and filter decisions locally