Module:MysteriesController

From Against the Storm Official Wiki

Documentation for this module may be created at Module:MysteriesController/doc

---
--- Serves the Mysteries template by capturing input and using it to control the display of data.
---
---@module MysteriesController
local MysteriesController = {}



--region Dependencies

local MysteriesData = require("Module:MysteriesData")

--endregion



--region Private constants

--endregion



--region Private member variables

local currentFrame

local mysteryIDs

--endregion



--region Private methods

local function selectIDs()

    mysteryIDs = MysteriesData.getAllMysteryIDs()
end

local function renderTable()

    local markup = ""

    for _, id in ipairs(mysteryIDs) do
        --markup = markup .. MysteriesData.getName(id) .. ":\n"
        --markup = markup .. "  " .. MysteriesData.getDescription(id) .. "\n"
        --markup = markup .. "  " .. MysteriesData.getIcon(id) .. "\n"
        markup = markup .. "  " .. MysteriesData.getCostDifficulty(id) .. "\n"
        markup = markup .. "  " .. MysteriesData.getCostLabel(id) .. "\n"
        --markup = markup .. "  " .. MysteriesData.getHostilityLevel(id) .. "\n"
        --markup = markup .. "  " .. MysteriesData.getSeason(id) .. "\n"

        --if MysteriesData.isStacksWithHostility(id) then
        --    markup = markup .. "true\n"
        --else
        --    markup = markup .. "false\n"
        --end
        --
        --if MysteriesData.isStacksWithYear(id) then
        --    markup = markup .. "true\n"
        --else
        --    markup = markup .. "false\n"
        --end
        --
        --if MysteriesData.isRemovedAfterYear(id) then
        --    markup = markup .. "true\n"
        --else
        --    markup = markup .. "false\n"
        --end
        --
        ----markup = markup .. "  " .. MysteriesData.getEffectID(id) .. "\n"
        --
        --if MysteriesData.isInCustomMode(id) then
        --    markup = markup .. "true\n"
        --else
        --    markup = markup .. "false\n"
        --end
        --
        ----markup = markup .. "  " .. MysteriesData.getVillagerPerkID(id) .. "\n"
        --markup = markup .. "  " .. MysteriesData.getNumberOfConditions(id) .. "\n"
    end

    return markup
end

--endregion



--region Public methods

---main
---@param frame table the MediaWiki frame provided by the template call
---@return string wiki markup to display
function MysteriesController.main(frame)

    currentFrame = frame

    selectIDs()
    if #mysteryIDs < 1 then
        return "No matching Forest Mysteries found."
    end

    -- Default display is table.
    return renderTable()
end

--endregion

return MysteriesController