User:Fewfre/sandbox/line

From the RuneScape Wiki, the wiki for all things RuneScape
Jump to: navigation, search
--
-- Sandbox module
--
-- To be used to test out ideas in the same way [[RuneScape:Sandbox]] is used
--

local p = {}

local yesno = require( 'Module:Yesno' )

function p.header( frame )
	local args = frame:getParent().args
	
	local tbl = mw.html.create( 'table' )
		:addClass( 'wikitable' )
		:addClass( 'infotableBonuses' )
		:css( 'text-align', 'center' )
	
	-- The class corresponds to the class all the items have in common. If they are different, "mixed" will add an additional column to specify it (further down).
	local class = args.class or args.type
	local classImages = {
		melee = '[[File:Attack.png|x34px|link=Melee]]',
		ranged = '[[File:Attack.png|x34px|link=Melee]]',
		magic = '[[File:Attack.png|x34px|link=Melee]]',
		all = '[[File:CombatSwords.png|All]]',
		hybrid = '[[File:CombatSwords.png|Hybrid]] Hybrid',
		mixed = '',
		none = ''
	}
	local classImage = classImages[string.lower(class)]
	if class and classImage == nil then
		classImage = class .. '<br />'
	elseif classImage ~= '' then
		classImage = classImage .. '<br />'
	end
	
	local skill = args.skill
	local skill2 = args.skill2
	
	-- define 1st row
	local tr1 = tbl:tag('tr')
	local th1 = tr1:tag('th')
		:attr( 'rowspan', '2' )
		:wikitext( classImage .. 'Items' )
		if not yesno(args.noinv) then th1:attr( 'colspan', '2' ) end
		th1:done()
	
	if class == 'mixed' then
		tr1:tag('th')
			:attr( 'rowspan', '2' )
			:wikitext( 'Type' )
			:done()
	end
	
	if skill then
		tr1:tag('th')
			:attr( 'rowspan', '2' )
			:wikitext( frame:preprocess( '{{Skill clickpic|'..skill..'}}')..'<br /><span style="font-size:90%;">Level</span>' )
			:done()
	end
	if skill2 then
		tr1:tag('th')
			:attr( 'rowspan', '2' )
			:wikitext( frame:preprocess( '{{Skill clickpic|'..skill2..'}}')..'<br /><span style="font-size:90%;">Level</span>' )
			:done()
	end
	
	local mainSpan = mw.html.create( 'span' )
		:css({ ['color'] = '#000' })
		:wikitext( 'Mainhand Info' )
		:done()
	local offSpan = mw.html.create( 'span' )
		:css({ ['color'] = '#000' })
		:wikitext( 'Off-hand Info' )
		:done()
	local attrSpan = mw.html.create( 'span' )
		:attr( 'title', 'Determines the character\'s endurance determined by their armour rating, life point boost, and prayer bonus' )
		:css({ ['color'] = '#000' })
		:wikitext( 'Attributes' )
		:done()
	local critSpan = mw.html.create( 'span' )
		:css({ ['color'] = '#000', ['font-size'] = '80%' })
		:wikitext( 'Critical Bonuses' )
		:done()
	
	tr1:tag('th')
		:attr( 'colspan', '3' )
		:wikitext( tostring(mainSpan) )
		:done()
	
	tr1:tag('th')
		:attr( 'colspan', '3' )
		:wikitext( '[[Off-hand weapons|' .. tostring(offSpan) .. ']]' )
		:done()
	
	tr1:tag('th')
		:attr( 'colspan', '3' )
		:wikitext( tostring(attrSpan) )
		:done()
	
	tr1:tag('th')
		:attr( 'colspan', '3' )
		:wikitext( '[[Critical hit|' .. tostring(critSpan) ..']]' )
		:done()
		
	if args.price then
		tr1:tag('th')
			:attr( 'rowspan', '2' )
			:wikitext( 'Price' )
			:done()
	end
			
	-- Rarely used anymore, may be a feature worth removing
	local image = args.image
	if image then
		local rowspan = 2 + tonumber(args.rows) + tonumber(args.tot)
		local caption = args.caption
		tr1:tag('th')
			:attr( 'rowspan', rowspan )
			:css({['width'] = '125px'})
			:wikitext( '[[File:'..image..'|'..caption..']]'..(caption and '<br /><small>'..caption..'</small>' or '') )
			:done()
	end
	-- Not sure if image2 is used at all anymore
	local image2 = args.image2
	if image2 then
		local rowspan = 2 + tonumber(args.rows) + tonumber(args.tot)
		local caption2 = args.caption2
		tr1:tag('th')
			:attr( 'rowspan', rowspan )
			:css({['width'] = '125px'})
			:wikitext( '[[File:'..image2..'|'..caption2..']]'..(caption2 and '<br /><small>'..caption2..'</small>' or '') )
			:done()
	end
	
	tr1:done()
	
	-- start 2nd row
	local tr2 = tbl:tag('tr')
	-- Mainhand stats
	tr2:tag('th')
		:attr( 'title', 'Mainhand attacking style' )
		:wikitext( '[[Attack types|<span style="color:#000">Style</span>]]' )
		:done()
	tr2:tag('th')
		:attr( 'title', 'Mainhand weapon damage' )
		:wikitext( 'Dmg' )
		:done()
	tr2:tag('th')
		:attr( 'title', 'Mainhand weapon accuracy' )
		:wikitext( 'Acc' )
		:done()
	-- Off-hand stats
	tr2:tag('th')
		:attr( 'title', 'Offhand attacking style' )
		:wikitext( '[[Attack types|<span style="color:#000">Style</span>]]' )
		:done()
	tr2:tag('th')
		:attr( 'title', 'Offhand weapon damage' )
		:wikitext( 'Dmg' )
		:done()
	tr2:tag('th')
		:attr( 'title', 'Offhand weapon accuracy' )
		:wikitext( 'Acc' )
		:done()
	-- Attributes
	tr2:tag('th')
		:wikitext( frame:preprocess( '{{Skill clickpic|Defence}}') )
		:done()
	tr2:tag('th')
		:wikitext( frame:preprocess( '{{Skill clickpic|Constitution}}') )
		:done()
	tr2:tag('th')
		:wikitext( frame:preprocess( '{{Skill clickpic|Prayer}}') )
		:done()
	-- Critical Bonuses
	tr2:tag('th')
		:wikitext( '[[File:Attack-icon.png|20px|link=Melee]]' )
		:done()
	tr2:tag('th')
		:wikitext( '[[File:Ranged-icon.png|20px|link=Ranged]]' )
		:done()
	tr2:tag('th')
		:wikitext( '[[File:Magic-icon.png|20px|link=Magic]]' )
		:done()
		
	tr2:done()
	
	return tostring(tbl)
end

return p

--Nothing atm.<!--
--
--><noinclude><div style="border:3px double brown; padding:0 5px;">A sandbox template for --[[User:Fewfre/sandbox]], used for reasons unknown.</div></noinclude>
--