Module:Treasure Chests

local p = {} local Data = mw.loadData("Module:Treasure Chests/Data")

local DataTable = require("Module:Data Table") local Franchise = require("Module:Franchise") local utilsArg = require("Module:UtilsArg") local utilsTable = require("Module:UtilsTable")

function p.Main(frame) local args = utilsArg.parse(frame:getParent.args, p.Templates["Treasure Chests"]) local cells = args.cells or {} local rows = DataTable.parseRows(cells)

local columns = p.getColumns(args.game) local dataTable = DataTable.printTable(rows, {		game = args.game,		columns = columns,	}) return dataTable end

function p.getColumns(game) local graphicsType = Franchise.graphics(game) local gameConfig = Data.games[game] or {} local defaultConfig = Data.defaults[graphicsType] local config = utilsTable.merge({}, defaultConfig, gameConfig) local columns = {}

local treasureChestColumn = string.format("Treasure Chest [Term][Nowrap]", config.treasureChest.fileType, config.treasureChest.fileSize) table.insert(columns, treasureChestColumn) local contentsColumn = string.format("Contents [Term][Nowrap]", config.contents.fileType, config.contents.fileSize) table.insert(columns, contentsColumn) if config.coordinates then table.insert(columns, "Coordinates [Nowrap]") end table.insert(columns, "Notes [Description]") return columns end

p.Templates = { ["Treasure Chests"] = { params = { game = { required = true, desc = "A game code.", type = "string", enum = Franchise.enum, },			["..."] = {				name = "cells", type = "content", trim = true, },		}	}, }

return p