Module:SortieList

local getArgs = require("Module:GetArgs") local find = require("Module:Utils").find local format = require("Module:StringInterpolation").format local ResourceIcons = require("Module:ResourceIcons")

local templates = {

header = {| class="article-table" border="0" cellpadding="1" cellspacing="1" style="width:100%;",

footer = "|}",

map_rows = [=[|- ! colspan="2" style="text-align:center;width:40%;" | World ${id}: ${name} ${name_en} ! Difficulty ! EXP/node ! Items ! Fluff text
 * rowspan="4" style="text-align:center;width:60%;" | ${banner}
 * ${difficulty}
 * ${ship_exp}
 * ${items_string}
 * ${strategy_name}
 * ${strategy_info}]=],

}

function formatItems(items) local item_names = { "fuel", "ammo", "steel", "bauxite", "bucket", "devmat", "conmat", "furniture_box_small", "furniture_box_medium", "furniture_box_large", }   if items == nil then return "?" end if items == false then return "None" end local images = {} for _, item_name in ipairs(item_names) do       if items[item_name] then local image = ResourceIcons[item_name] and string.format("", ResourceIcons[item_name]) or "?" table.insert(images, image) end end return table.concat(images, " ") end

function formatDifficulty(stars) return stars and string.rep("☆", stars) or "?" end

function loadMapData(world_id, id) local success, table = pcall(function return require(string.format("Module:World %d/%s", world_id, id)) end) return success and table or {} end

function formatTable(maps) local rows = {} table.insert(rows, templates.header) for _, id in ipairs(maps) do       local world_id = string.match(id, "%d") or "?" local map_data = loadMapData(world_id, id) table.insert(rows, format{           templates.map_rows,            id = id,            link = string.format("World %d#%s", world_id, id),            banner = string.format("", id),            name = map_data.name or "?",            name_en = map_data.name_en or "?",            difficulty = formatDifficulty(map_data.stars),            ship_exp = map_data.ship_exp or "?",            items_string = formatItems(map_data.items),            strategy_name = map_data.strategy_name or "?",            strategy_info = map_data.strategy_info or "?",            -- strategy_name_en            -- strategy_info_en            -- hp            -- kills_required            -- hq_non_boss_exp            -- hq_boss_exp            -- eo        }) end table.insert(rows, templates.footer) return table.concat(rows, "\n") end

local SortieList = {}

function SortieList.format(frame, args) args = args or getArgs{frame = frame:getParent} return formatTable(args) end

-- SortieList.t = SortieList.format(nil, { "1-1", "1-2", "1-3", "1-4" }) -- print(p.t)

return SortieList