Module:QuestList

Revision as of 19:20, 11 December 2024 by Drekryan (talk | contribs) (work in progress, will finish later)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

require('strict')
require('Module:Mw.html extension')
local parse = require('Module:Param Parse')

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local episode = ''
	local quest_type = ''
	
	if (args.episode) then
		episode = ('[[Episode::%s]]'):format( args.episode )
	end
	
	if (args.type) then
		quest_type = ('[[Quest type::%s]]'):format( args.type )
	end
	
	local data = mw.smw.ask{ 
		'[[Category:Quests]]',
		episode,
		quest_type,
		'[[Name::+]]',
		'?Difficulty',
		'?Requirements',
		'order=asc',
		'sort=override_seq,Difficulty',
		'limit=500',
		'link=all'
	}
	local table = mw.html.create('table')
		:addClass('wikitable quest-table sortable align-center-2 align-left-3')
		:css{
			['style'] = '55%'
		}
		:attr{ cellspacing = '3' }
		:IF( args.episode )
			:tag('tr')
				:tag('th')
				:attr('colspan', 3)
					:wikitext( parse.episode_func( args.episode ) )
				:done()
			:done()
		:END()
		:tag('tr')
			:tag('th')
				:wikitext("Quest")
			:done()
			:tag('th')
				:wikitext("Difficulty")
			:done()
			:tag('th')
				:wikitext("Requirements")
			:done()
		:done()
		for _, quest in ipairs( data ) do
			table
				:tag('tr')
				:tag('td')
					:wikitext( quest[1] )
				:done()
				:tag('td')
					:wikitext( parse.difficulty_func( tostring( quest['Difficulty']) ) )
				:done()
				:tag('td')
					:IF(quest['Requirements'])
						:tag('div')
							:addClass('lighttable checklist')
							:newline()
							:wikitextIf( quest['Requirements'], quest['Requirements'] )
							:newline()
						:done()
					:ELSE()
						:tag('p')
							:wikitext('None')
						:done()
					:END()
				:done()
			:done()
		end

	return table
end

return p