Module:MysteriesController: Difference between revisions

From Against the Storm Official Wiki
(Created to serve a mysteries template)
 
m (Started; not ready yet.)
 
Line 43: Line 43:


     for _, id in ipairs(mysteryIDs) do
     for _, id in ipairs(mysteryIDs) do
         markup = markup .. MysteriesData.getName(id) .. ":\n"
         --markup = markup .. MysteriesData.getName(id) .. ":\n"
         markup = markup .. "  " .. MysteriesData.getDescription(id) .. "\n"
         --markup = markup .. "  " .. MysteriesData.getDescription(id) .. "\n"
         markup = markup .. "  " .. MysteriesData.getIcon(id) .. "\n"
         --markup = markup .. "  " .. MysteriesData.getIcon(id) .. "\n"
         markup = markup .. "  " .. MysteriesData.getCostDifficulty(id) .. "\n"
         markup = markup .. "  " .. MysteriesData.getCostDifficulty(id) .. "\n"
         markup = markup .. "  " .. MysteriesData.getCostLabel(id) .. "\n"
         markup = markup .. "  " .. MysteriesData.getCostLabel(id) .. "\n"
         markup = markup .. "  " .. MysteriesData.getHostilityLevel(id) .. "\n"
         --markup = markup .. "  " .. MysteriesData.getHostilityLevel(id) .. "\n"
         markup = markup .. "  " .. MysteriesData.getSeason(id) .. "\n"
         --markup = markup .. "  " .. MysteriesData.getSeason(id) .. "\n"
         if MysteriesData.isStacksWithHostility(id) then
 
            markup = markup .. "true\n"
         --if MysteriesData.isStacksWithHostility(id) then
         else
        --    markup = markup .. "true\n"
            markup = markup .. "false\n"
         --else
         end
        --    markup = markup .. "false\n"
         if MysteriesData.isStacksWithYear(id) then
         --end
            markup = markup .. "true\n"
         --
         else
        --if MysteriesData.isStacksWithYear(id) then
            markup = markup .. "false\n"
        --    markup = markup .. "true\n"
         end
         --else
         if MysteriesData.isRemovedAfterYear(id) then
        --    markup = markup .. "false\n"
            markup = markup .. "true\n"
         --end
         else
         --
            markup = markup .. "false\n"
        --if MysteriesData.isRemovedAfterYear(id) then
         end
        --    markup = markup .. "true\n"
         --markup = markup .. "  " .. MysteriesData.getEffectID(id) .. "\n"
         --else
         if MysteriesData.isInCustomMode(id) then
        --    markup = markup .. "false\n"
            markup = markup .. "true\n"
         --end
         else
         --
            markup = markup .. "false\n"
        ----markup = markup .. "  " .. MysteriesData.getEffectID(id) .. "\n"
         end
         --
         --markup = markup .. "  " .. MysteriesData.getVillagerPerkID(id) .. "\n"
        --if MysteriesData.isInCustomMode(id) then
         markup = markup .. "  " .. MysteriesData.getNumberOfConditions(id) .. "\n"
        --    markup = markup .. "true\n"
         --else
        --    markup = markup .. "false\n"
         --end
         --
        ----markup = markup .. "  " .. MysteriesData.getVillagerPerkID(id) .. "\n"
         --markup = markup .. "  " .. MysteriesData.getNumberOfConditions(id) .. "\n"
     end
     end



Latest revision as of 20:01, 8 July 2024

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