Module:Statistic/Legacy

Awaiting deprecation local stat = {}

local metadataPages = { "Module:Statistic/Legacy/Fleet", "Module:Statistic/Legacy/Ship", "Module:Statistic/Legacy/Module", "Module:Statistic/Legacy/Weapon", "Module:Statistic/Legacy/Squadron", "Module:Statistic/Legacy/Armor", "Module:Statistic/Legacy/Shield", "Module:Statistic/Legacy/Ablative Armor", "Module:Statistic/Legacy/Screen", }

-- Duplicate of current function function stat.colorStatText( text ) return string.format("%s ", text) end

function stat.getBasicStatistics( frame ) local page = frame:preprocess(""):gsub("/doc", "") return assert( require(page).basicStatistics, string.format("basicStatistics not found in page %s", page) ) end

function stat.getCompositeStatistics( frame ) local page = frame:preprocess(""):gsub("/doc", "") return assert( require(page).compositeStatistics, string.format("compositeStatistics not found in page %s", page) ) end

-- Display statistic as an informational tooltip that appears as a link. 'page' should be one of the metadataPages. function stat.helpTooltip( page, key ) local data = require(page).basicStatistics[key] local frame = mw.getCurrentFrame return frame:expandTemplate{ title = "Help Tooltip", args = { "" .. data.displayName .. "", frame:preprocess(data.overview) } } end

-- Display statistic as an informational tooltip at appears as an image. 'page' should be one of the metadataPages. function stat.imageTooltip( page, key ) local data = require(page).basicStatistics[key] local frame = mw.getCurrentFrame return frame:expandTemplate{ title = "Image Tooltip", args = { image = data.displayImage, link = data.displayName } } end

-- Display the documentation for data page. function stat.documentation( frame ) local list = mw.html.create("ul") for k,v in ipairs(metadataPages) do		list :tag("li"):wikitext(string.format("%s", v)) :done end -- Sort the table first by name local sortedBasicStats = {} for k,v in pairs(stat.getBasicStatistics(frame)) do		table.insert(sortedBasicStats, v)	end table.sort(sortedBasicStats, function(a, b) return a.displayName < b.displayName end) local metadata = mw.html.create("table"):addClass("wikitable"):addClass("sortable"):css("width", "100%"):css("text-align", "center") :tag("tr") :tag("th"):attr("scope", "col"):wikitext("Name"):done :tag("th"):attr("scope", "col"):wikitext("Image"):done :tag("th"):attr("scope", "col"):wikitext("Overview"):done :tag("th"):attr("scope", "col"):wikitext("Details"):done :tag("th"):attr("scope", "col"):wikitext("Relationship"):done :done for k, v in pairs(sortedBasicStats) do assert(v.displayUnits, "Field 'units' is missing for key '" .. k .. "'") if v.displayUnits == "" or v.displayUnits == "%" or v.displayUnits == "Time" then metadata :tag("tr") :tag("td"):wikitext(tostring( assert(v.displayName, "Field 'name' is missing for key '" .. k .. "'") )):done :tag("td"):wikitext(""):done :tag("td"):wikitext(string.format( assert(v.overview, "Field 'overview' is missing for key '" .. k .. "'"), stat.colorStatText("X") )):done :tag("td"):wikitext(tostring( assert(v.details, "Field 'details' is missing for key '" .. k .. "'") )):done :tag("td"):wikitext(mw.text.nowiki( assert(v.relation, "Field 'relation' is missing for key '" .. k .. "'") )):done :done else metadata :tag("tr") :tag("td"):wikitext(tostring( assert(v.displayName, "Field 'name' is missing for key '" .. k .. "'") )):done :tag("td"):wikitext(""):done :tag("td"):wikitext(string.format( assert(v.overview, "Field 'overview' is missing for key '" .. k .. "'"), stat.colorStatText("X") .. " " ..					v.displayUnits )):done :tag("td"):wikitext(tostring( assert(v.details, "Field 'details' is missing for key '" .. k .. "'") )):done :tag("td"):wikitext(mw.text.nowiki( assert(v.relation, "Field 'relation' is missing for key '" .. k .. "'") )):done :done end end return "List of stat metadata pages:\n" .. tostring(list) .. tostring(metadata) end

return stat