diff --git a/.luacheckrc b/.luacheckrc index 73a56b4..0f7d7aa 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -3,6 +3,7 @@ globals = { "Focus", + "Day", "Util", "Decision", "Situation", diff --git a/impostor.inc b/impostor.inc index 4dd1c2c..8ebe699 100644 --- a/impostor.inc +++ b/impostor.inc @@ -8,6 +8,7 @@ system/system.util.lua system/system.print.lua system/system.input.lua system/system.focus.lua +system/system.day.lua system/system.ui.lua audio/audio.manager.lua audio/audio.songs.lua @@ -28,6 +29,7 @@ decision/decision.play_ddr.lua map/map.manager.lua map/map.bedroom.lua map/map.street.lua +map/map.office.lua screen/screen.manager.lua screen/screen.home.lua screen/screen.toilet.lua diff --git a/inc/audio/audio.manager.lua b/inc/audio/audio.manager.lua index 583ffd2..2e9f0eb 100644 --- a/inc/audio/audio.manager.lua +++ b/inc/audio/audio.manager.lua @@ -19,7 +19,6 @@ function Audio.music_play_room_street_1() end --- @within Audio function Audio.music_play_room_street_2() end --- Plays room music. --- TODO: function name is incomplete, determine the correct room identifier --- @within Audio function Audio.music_play_room_() end --- Plays room work music. diff --git a/inc/init/init.context.lua b/inc/init/init.context.lua index 62cf5bb..f45855a 100644 --- a/inc/init/init.context.lua +++ b/inc/init/init.context.lua @@ -37,7 +37,8 @@ function Context.initial_data() game = { current_screen = "home", current_situation = nil, - } + }, + day_count = 1, } end diff --git a/inc/init/init.meter.lua b/inc/init/init.meter.lua index 31d1ef1..c904311 100644 --- a/inc/init/init.meter.lua +++ b/inc/init/init.meter.lua @@ -98,6 +98,7 @@ function Meter.update() end m.timer_progress = m.timer_progress + (1 / meter_timer_duration) if m.timer_progress >= 1 then + Day.increase() m.timer_progress = m.timer_progress - 1 m.ism = math.max(0, m.ism - meter_timer_decay_per_revolution) m.wpm = math.max(0, m.wpm - meter_timer_decay_per_revolution) diff --git a/inc/init/init.module.lua b/inc/init/init.module.lua index 700caa5..50ea344 100644 --- a/inc/init/init.module.lua +++ b/inc/init/init.module.lua @@ -12,3 +12,4 @@ Input = {} Sprite = {} Audio = {} Focus = {} +Day = {} \ No newline at end of file diff --git a/inc/map/map.office.lua b/inc/map/map.office.lua new file mode 100644 index 0000000..42a7202 --- /dev/null +++ b/inc/map/map.office.lua @@ -0,0 +1,9 @@ +Map.register({ + id = "office", + from_x = 60, + from_y = 0, + width = 30, + height = 17, + to_x = 0, + to_y = 0, +}) \ No newline at end of file diff --git a/inc/screen/screen.home.lua b/inc/screen/screen.home.lua index 49d2bda..a801ec1 100644 --- a/inc/screen/screen.home.lua +++ b/inc/screen/screen.home.lua @@ -5,5 +5,5 @@ Screen.register({ "go_to_toilet", "go_to_walking_to_office", }, - background = "bedroom", + background = "bedroom" }) diff --git a/inc/screen/screen.office.lua b/inc/screen/screen.office.lua index 3d5320c..b7a0102 100644 --- a/inc/screen/screen.office.lua +++ b/inc/screen/screen.office.lua @@ -1,7 +1,6 @@ Screen.register({ id = "office", name = "Office", - background_color = Config.colors.dark_grey, decisions = { "play_button_mash", "play_rhythm", @@ -12,4 +11,5 @@ Screen.register({ situations = { "drink_coffee", }, + background = "office" }) diff --git a/inc/screen/screen.toilet.lua b/inc/screen/screen.toilet.lua index dae74c3..4ae2a8c 100644 --- a/inc/screen/screen.toilet.lua +++ b/inc/screen/screen.toilet.lua @@ -30,8 +30,7 @@ Screen.register({ local bar_x = math.floor((sw - bar_w) / 2) local bar_h = 4 - -- TODO: Add day counter - Print.text_center("day 1", cx, 10, Config.colors.white) + Print.text_center("day " .. Context.day_count, cx, 10, Config.colors.white) local narrative = "reflecting on my past and present\n...\nboth eventually flushed." local wrapped = UI.word_wrap(narrative, 38) diff --git a/inc/system/system.day.lua b/inc/system/system.day.lua new file mode 100644 index 0000000..8b03d01 --- /dev/null +++ b/inc/system/system.day.lua @@ -0,0 +1,11 @@ +local _day_increase_handlers = {} + +function Day.increase() + Context.day_count = Context.day_count + 1 + for _, handler in ipairs(_day_increase_handlers) do + handler() + end +end +function Day.register_handler(handler) + table.insert(_day_increase_handlers, handler) +end