Zelda Wiki

OoT Navi.png

Hey! Listen!

This wiki contains spoilers! Read at your own risk!

READ MORE

Zelda Wiki
Advertisement
Zelda Wiki
10,308
pages
This is the main module for the following templates:
local File = require("Module:File")
local Franchise = require("Module:Franchise")
local Term = require("Module:Term")
local utilsArg = require("Module:UtilsArg")
local utilsLayout = require("Module:UtilsLayout")
local utilsMarkup = require("Module:UtilsMarkup")
local utilsTable = require("Module:UtilsTable")

local p = {}
local h = {}

function p.Main(frame)
	local args, err = utilsArg.parse(frame:getParent().args, p.Templates["Trading Quest"])
	if err then
		return utilsMarkup.categories(err.categories)
	end
	return p.printTradingQuestTable(args.game, args.tradingSequence)
end

function p.printTradingQuestTable(game, tradingSequence)
	local rows = utilsTable.map(tradingSequence, h.row(game))
	return utilsLayout.table({
		headers = {"Item", "Character", "Location", "Requirements"},
		rows = rows
	})
end

function h.row(game)
	local cellStyles = {
		["text-align"] = "center"
	}
	return function(item)
		local icon = File.icon(game, item.item, {
			size = "48x48px"
		})
		local row = {
			{
				content = icon .. "<br>" .. utilsMarkup.bold(h.printTerm(game, item.item)),
				styles = cellStyles,
			},
			{
				content = item.character and h.printTerm(game, item.character) or "—",
				styles = cellStyles,
			},
			{
				content = item.location and h.printTerm(game, item.location) or "—",
				styles = cellStyles,
			},
			{
				content = item.requirements or "—",
				styles = not item.requirements and cellStyles or nil,
			}
		}
		return row
	end
end

function h.printTerm(game, page)
	return Term.printTerm({
		game = game,
		page = page,
		link = "link",
	})
end

p.Templates = {
	["Trading Quest"] = {
		purpose = "For {{Term|Series|Trading Quest|link}} tables.",
		format = "block",
		repeatedGroup = {
			name = "tradingSequence",
			params = {"item", "character", "location", "requirements"},
			count = 20,
		},
		params = {
			[1] = {
				name = "game",
				type = "string",
				required = true,
				enum = Franchise.enumGames(),
				desc = "[[Data:Franchise|Game code]].",
				inline = true,
				trim = true,
			},
			item = {
				type = "wiki-page-name",
				desc = "Name of the wiki page for the item.",
				trim = true,
			},
			character = {
				type = "wiki-page-name",
				desc = "Name of the wiki page for the character that gives the item, if applicable.",
				trim = true,
				nilIfEmpty = true,
			},
			location = {
				type = "wiki-page-name",
				desc = "Name of the wiki page for the location where the item is obtained, if applicable.",
				trim = true,
				nilIfEmpty = true,
			},
			requirements = {
				type = "content",
				desc = "Any requirements needed to obtain the item.",
				trim = true,
				nilIfEmpty = true,
			},
		},
		examples = {
			{
				[1] = "LANS",
				
				item1 = "Yoshi Doll",
				character1 = "Trendy Gamester",
				location1 = "Trendy Game",
				requirements1 = "Having 10 {{Plural|LANS|Rupee|link}}.",
				
				item2 = "Ribbon",
				character2 = "Mamasha",
				location2 = "Quadruplet's House",
				requirements2 = ""
			},
		},
	},
}

return p
Advertisement