Module:InfoboxQuest

local p = {} local h = {} local infobox = require("Module:Infobox") local utilsCode = require("Module:UtilsCode") local utilsIcons = require("Module:UtilsIcons") local utilsItems = require("Module:UtilsItems") local utilsString = require("Module:UtilsString")

local FIELDS = {{parameter = "type", content = "", caption = "Type", type = "inline"}, {parameter = "category", content = "", caption = "Category", type = "inline"}, {parameter = "location", content = "", caption = "Location", type = "inline"}, {parameter = "level", content = "", caption = "Level required", type = "inline"}, {parameter = "participants", content = "", caption = "Recommended participants", type = "inline"}, {parameter = "reward", content = "", caption = "Reward(s)", type = "wide"}}

function p._Main(frame) local args = frame:getParent.args return p.Main(args) end

function p.Main(args) local fields = FIELDS for key, field in ipairs(fields) do		if field["parameter"] == "location" then field["content"] = "" .. args[field["parameter" .. "]]"		elseif field["parameter"] == "participants" then field["content"] = h.FormatParticipants(args["participants"]) elseif field["parameter"] == "reward" then field["content"] = h.FormatRewards(args) else field["content"] = args[field["parameter"]] end end return infobox.CreateInfobox(args["name"], {content = h.FormatImage(args["type"], args["location"])}, fields) end

-- Formats image function h.FormatImage(type, location) local result = "File:" .. location if not utilsCode.IsEmpty(type) then result = result .. " " .. type .. " "	end result = result .. " Quest Sprite.png" return result end

-- Formats participants function h.FormatParticipants(number) local result = "" local counter = 0 while counter < tonumber(number) do result = result .. ""		counter = counter + 1 end return result end

-- Formats rewards function h.FormatRewards(args) local rewardsContainer = mw.html.create("div") :addClass("quest-rewards-container") -- Exp if not utilsCode.IsEmpty(args["exp_reward"]) then rewardsContainer:node(mw.html.create("div")				:addClass("quest-rewards-item-exp")				:wikitext(args["exp_reward"] .. " " .. utilsIcons.Display("XP"))) end -- Emotes if not utilsCode.IsEmpty(args["emote_reward"]) then for key, emote in ipairs(utilsString.Explode(args["emote_reward"], ",")) do			rewardsContainer:node(mw.html.create("div")				:addClass("quest-rewards-item")				:node(utilsItems.DisplayEmote(emote))) end end -- Items if not utilsCode.IsEmpty(args["item_reward"]) then for key, item in ipairs(utilsString.Explode(args["item_reward"], ",")) do			rewardsContainer:node(mw.html.create("div")				:addClass("quest-rewards-item")				:node(utilsItems.DisplayItem(item))) end end -- Titles if not utilsCode.IsEmpty(args["title_reward"]) then for key, title in ipairs(utilsString.Explode(args["title_reward"], ",")) do			rewardsContainer:node(mw.html.create("div")				:addClass("quest-rewards-item")				:node(utilsItems.DisplayTitle(title))) end end return tostring(rewardsContainer) end

return p