section and within annotations for ldoc
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful

This commit is contained in:
2026-02-25 23:24:53 +01:00
parent 297ee8b622
commit 777c27aa54
27 changed files with 175 additions and 2 deletions

View File

@@ -3,9 +3,11 @@ local SAVE_GAME_MAGIC_VALUE_ADDRESS = 0
local SAVE_GAME_MAGIC_VALUE = 0xCA
--- Global game context.
--- @section Context
Context = {}
--- Gets initial data for Context.
--- @within Context
-- @return table Initial context data.
function Context.initial_data()
return {
@@ -28,6 +30,7 @@ function Context.initial_data()
end
--- Resets game context to initial state.
--- @within Context
function Context.reset()
local initial_data = Context.initial_data()
for k in pairs(Context) do
@@ -42,6 +45,7 @@ function Context.reset()
end
--- Starts a new game.
--- @within Context
function Context.new_game()
Context.reset()
Context.game_in_progress = true
@@ -50,12 +54,14 @@ function Context.new_game()
end
--- Saves the current game state.
--- @within Context
function Context.save_game()
if not Context.game_in_progress then return end
mset(SAVE_GAME_MAGIC_VALUE, SAVE_GAME_MAGIC_VALUE_ADDRESS, SAVE_GAME_BANK)
end
--- Loads a saved game state.
--- @within Context
function Context.load_game()
if mget(SAVE_GAME_MAGIC_VALUE_ADDRESS, SAVE_GAME_BANK) ~= SAVE_GAME_MAGIC_VALUE then
Context.new_game()