FANDOM


local p = {}
 
local commas = require('Module:Addcommas')
local skill_names = require('Module:Skill_list')
local experience = require('Module:Experience')
 
function p.main(frame)
	local hs_data
	local arg = frame.args[1]
	if string.match(arg, '^[0-9]') then
		hs_data = arg
	else
		hs_data = frame:expandTemplate({title = frame.args[1]})
	end
 
	-- Test data:
	--local hs_data = '25555,2549,345857118 133022,99,13306579 171658,96,9890104 228079,96,9711037 146185,99,15125647 147403,97,11201008 19363,99,14484968 203557,97,10888874 45655,99,15005540 177158,96,9782931 111073,99,13113633 103725,96,10236259 61145,99,13651734 30463,99,13723192 54551,96,10256997 55775,96,10599429 87593,96,10522626 42857,98,12523164 56460,96,10125300 36729,99,13889972 46495,98,12706754 58561,98,12528246 49183,97,10989827 41875,98,12488913 32387,99,13464559 24278,111,45055570 27305,96,10584255 -1,-1 -1,-1 10391,4341169 -1,-1 -1,-1 -1,-1 -1,-1 139911,600 -1,-1 -1,-1 -1,-1 10275,1347 -1,-1 18910,483 30325,605 7572,1470000 -1,-1 58994,2 -1,-1 -1,-1 -1,-1 542,159'
 
	local rank = {}
	local level = {}
	local xp = {}
	local i = 0
	local hs_skills = mw.text.split(hs_data,' ')
	for i, v in ipairs(hs_skills) do    
		if i == #skill_names + 2 then
			break
		end
		local skill_data = mw.text.split(v,',')
		rank[i] = tonumber(skill_data[1])
		level[i] = tonumber(skill_data[2])
		xp[i] = tonumber(skill_data[3])
	end
 
	local barwidth = 150
 
	local t = mw.html.create('table'):addClass('wikitable sortable')
 
	t:tag('tr')
		:tag('th'):attr('title', 'Default sort'):done()
		:tag('th'):wikitext('Skills'):done()
		:tag('th'):wikitext('Level'):done()
		:tag('th'):wikitext('Rank'):done()
		:tag('th'):wikitext('Experience'):done()
		:tag('th'):wikitext('XP of next level'):done()
		:tag('th'):wikitext('% done'):css('min-width',barwidth..'px'):done()
		:tag('th'):wikitext('XP until next'):done()
 
	for i=1,#skill_names+1 do
		if i == 1 then
			t:tag('tr')
				:tag('td')
					:tag('span'):css('display', 'none'):wikitext(string.format('%02d', i)):done()
				:done()
				:tag('th'):wikitext('Overall'):done()
				:tag('td'):wikitext(level[i]):done()
				:tag('td'):wikitext(commas._add(rank[i])):done()
				:tag('td'):wikitext(commas._add(xp[i])):done()
				:tag('td'):done()
				:tag('td'):done()
				:tag('td'):done()
		else
			local name = skill_names[i - 1]
 
			--local max_level
			--if name == 'Dungeoneering' then
			--  max_level = 120
			--else
			--  max_level = 99
			--end
 
			local virtlevel = experience.level_at_xp_unr({args = {xp[i]}})
 
			local virtstr = ''
			if virtlevel ~= level[i] then
				virtstr = ' (' .. virtlevel .. ')'
			end
 
			local nextxp = experience.xp_at_level_unr({args = {virtlevel + 1}})
			local tonext = nextxp - xp[i]
			local max_tonext = experience.level_to_level_unr({args = {virtlevel, virtlevel + 1}})
 
			local percent = 100 - tonext / max_tonext * 100
 
			local barwidth = math.floor(percent * barwidth / 100) .. 'px'
 
			t:tag('tr')
				:tag('td')
					:tag('span'):css('display', 'none'):wikitext(string.format('%02d', i)):done()
				:done()
				:tag('th'):wikitext(name):done()
				:tag('td'):wikitext(level[i] .. virtstr):done()
				:tag('td'):wikitext(commas._add(rank[i])):done()
				:tag('td'):wikitext(commas._add(xp[i])):done()
				:tag('td'):wikitext(commas._add(nextxp)):done()
				:tag('td'):css({height = '20px', border = '1px solid #bbbbbb', ['margin-bottom'] = '4px'})
					:tag('span'):css('display', 'none'):wikitext(string.format('%03d', math.floor(percent))):done()
					:tag('div'):css({width = percent .. '%', display = 'block', background = '#afa487', height = '100%', float = 'left'})
						:tag('span'):css({position = 'relative', left = '3px'})
							:tag('span'):css({position = 'absolute', ['white-space'] = 'nowrap'}):wikitext(math.floor(percent) .. '%')
							:done()
						:done()
					:done()
				:done()
				:tag('td'):wikitext(commas._add(tonext)):done()
		end
	end
 
	return t
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.