Module:Fighter

From Wavu Wiki, the 🌊 wavy Tekken wiki
Revision as of 07:23, 11 November 2021 by RogerDodger (talk | contribs) (wip punishers bar graph)

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

local p = {};

p.fighters = {
	"Akuma", "Alisa", "Anna", "Armor King", "Asuka",
	"Bob", "Bryan", "Claudio", "Devil Jin", "Dragunov",
	"Eddy", "Eliza", "Fahkumram", "Feng", "Ganryu",
	"Geese", "Gigas", "Heihachi", "Hwoarang", "Jack-7",
	"Jin", "Josie", "Julia", "Katarina", "Kazumi",
	"Kazuya", "King", "Kuma", "Kunimitsu", "Lars",
	"Law", "Lee", "Lei", "Leo", "Leroy",
	"Lidia", "Lili", "Lucky Chloe", "Marduk", "Master Raven",
	"Miguel", "Negan", "Nina", "Noctis", "Paul",
	"Shaheen", "Steve", "Xiaoyu", "Yoshimitsu", "Zafina"
}

p.list = function()
	local r = ''
	for _, f in ipairs(p.fighters) do
		r = r .. "* [[" .. f .. "]]\n"
	end
	return r
end

p.class = function(frame)
	local name = frame.args[1]
	return p._class(name)
end

p._class = function(name)
	local r = name:lower():gsub("%s+","-")
	return r
end

p.punishers = function(frame)
	local name = frame.args[1]
	return p._punishers(name)
end

p._punishers = function(name)
	data = mw.loadData('Module:Fighter/punishers')
	subject = data.block[name]
	if (subject == nil) then
		error("Punishers not defined in [[Module:Fighter/punishers]] for " .. name)
	end
	
	local ret = ""
	for pos,punishers in ipairs(subject) do
		local root = mw.html.create('div'):attr('class', 'punishers')
		root:node(mw.html.create("div")
			:attr('class', 'punishers-label')
			:wikitext(pos:gsub("^%l", string.upper) .. "ing")
		)
		local grid = mw.html.create('div'):attr('class', 'punishers-grid')
		root:node(grid)
		
		best = {}
		for i = 1,50 do
			if punishers[i] ~= nil or (i >= 10 and i <= 15) then
				local curr = punishers[i]
				for k,v in ipairs(curr) do
					if best[v] == nil or best[v] < k then
						best[v] = k
					end
				end
				bestInvert = {}
				for k,v in ipairs(best) do
					bestInvert[v] = k
				end
				if bestInvert[true] ~= nil then
					for k,v in ipairs(bestInvert) do
						if k == true then break end
						bestInvert[k] = nil
					end
				end
				local row = mw.html.create('div'):attr('class', 'punishers-row')
				row:node(mw.html.create('div')
					:attr('class', 'punishers-startup')
					:wikitext("-" .. i)
				)
				local bars = mw.html.create('punishers-bars')
				
			end
		end
		
		ret = ret .. root
	end
end

return p