Fire Emblem Heroes Wiki
Fire Emblem Heroes Wiki
Documentation for this module may be created at Module:GetFancyMapName/doc
local Util = require 'Module:Util'
local cargo = mw.ext.cargo
local escq = require 'Module:EscQ'.main1
local p = {}

function p.getFancyName(frame)
	local pageName = frame:callParserFunction('#titleparts', frame.args[1])
	local data = cargo.query( "Maps", "BookGroup,MapName,MapGroup", { where= "_pageName='" .. escq(pageName) .. "'" } )[1]
	if data == nil then
		return pageName
	end
	return constructFancyName(pageName,data.BookGroup,data.MapName,data.MapGroup)
end

function p.constructFancyName(frame)
	return constructFancyName(frame.args[1], frame.args[2], frame.args[3], frame.args[4])
end

function constructFancyName(pageName,BookGroup,MapName,MapGroup)
	local fancyName = ""
	if not Util.isNilOrEmpty(BookGroup) then
		fancyName = BookGroup .. ": "
	elseif MapGroup == "Tempest Trials" then
		fancyName = "Tempest Trials: "
	end
	if not Util.isNilOrEmpty(MapName) then
		fancyName = fancyName .. MapName
	else
		fancyName = fancyName .. pageName
	end
	return fancyName
end

return p