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 rows = DataTable.parseRows(args.cells or {}) local config = p.getConfig(args.game) local dataTable = DataTable.printTable(rows, {		game = args.game,		columns = {			 string.format("Treasure Chest [Term][Nowrap]", config.treasureChest.fileType, config.treasureChest.fileSize),			 string.format("Contents [Term][Nowrap]", config.contents.fileType, config.contents.fileSize),			 "Coordinates [Nowrap]",			 "Notes [Description]",		},		optionalColumns = {3},	}) return dataTable end

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

p.Templates = { ["Treasure Chests"] = { params = { game = { required = true, desc = "A game code.", type = "string", enum = Franchise.enum, },			["..."] = {				name = "cells", type = "content", trim = true, },		},		tableParams = { {				name = "treasureChest", desc = "The type of Treasure Chest.", tags = {"Image", "Term", "Nowrap"}, },			{				name = "contents", desc = "The contents of the Treasure Chest.", tags = {"Image", "Term", "Nowrap"}, },			{				name = "coordinates", desc = "Precise location of the Treasure Chest. For games which do not support coordinates, you may use the in-game dungeon maps to indicate the location of Treasure Chests in dungeons.", optional = true, tags = {"Nowrap"}, },			{				name = "notes", desc = "Notes on how to locate the Treasure Chest in the area.", tags = {"Description"}, },		},	}, }

return p