Module:Archetype

From Wavu Wiki, the 🌊 wavy Tekken wiki
Revision as of 07:37, 5 January 2022 by RogerDodger (talk | contribs) (Created page with "local G = require("Module:G") local p = {} local json = mw.title.makeTitle("User", "RogerDodger/archetypes.json"):getContent() local data = mw.text.jsonDecode(json) local la...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Archetype/doc

local G = require("Module:G")
local p = {}

local json = mw.title.makeTitle("User", "RogerDodger/archetypes.json"):getContent()
local data = mw.text.jsonDecode(json)

local labels = { "Poke", "Mixup", "Okiwaza", "Whiff punish", "Okizeme" }

p.main = function(frame)
	char = frame.args[1]
	return p._main(char)
end

p.all = function()
	local ranks = {}
	for _,fighter in ipairs(data["unsorted"]) do
		ranks[fighter] = {}
	end
	
	for _,label in ipairs(labels) do
		for i,fighter in ipairs(data[label]) do
			ranks[fighter][label] = i
		end
	end
	
	local wikitable = mw.html.create('table'):addClass('wikitable sortable')
	
	-- Headings
	local heads = mw.html.create('tr')
	heads:node(mw.html.create('th'):wikitext("Character"))
	for _,label in ipairs(labels) do
		heads:node(mw.html.create('th'):wikitext(label))
	end
	heads:node(mw.html.create('th'):wikitext("Total"))
	wikitable:node(heads)
	
	-- Body
	for _,fighter in ipairs(data["unsorted"]) do
		local row = mw.html.create('tr')
		local n = 0
		row:node(mw.html.create('td'):wikitext("[[" .. fighter .. "]]"))
		for _,label in ipairs(labels) do
			local i = ranks[fighter][label]
			n = n + i
			row:node(mw.html.create('td'):wikitext(i):addClass(G._main(i,1,50,true)))
		end
		row:node(mw.html.create('td'):wikitext(n))
		wikitable:node(row)
	end
	
	return wikitable
end

return p