Module:QuestList: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
mNo edit summary
No edit summary
Line 1: Line 1:
require('strict')
require('strict')
require('Module:Mw.html extension')
require('Module:Mw.html extension')
local purge = require('Module:Purge')._purge
local parse = require('Module:Param Parse')
local parse = require('Module:Param Parse')


Line 23: Line 24:
local table = mw.html.create('table')
local table = mw.html.create('table')
if (episodes == nil) then
:addClass('wikitable quest-table align-center-2 align-center-3 align-left-4')
table:wikitext("No Quests available for " .. args.episode .. " " .. purge('source-'..mw.uri.anchorEncode(args.episode), '(update)', 'span'))
:css{
else
['width'] = '55%'
}
table
:addClass('wikitable quest-table align-center-2 align-center-3 align-left-4')
:attr{ cellspacing = '3' }
:css{
['width'] = '55%'
for _, episode in ipairs(episodes) do
table
}
:attr{ cellspacing = '3' }
:tag('tr')
:tag('th')
for _, episode in ipairs(episodes) do
:attr('colspan', 4)
table
:wikitextIf(episode.Premium == true, '[[File:Premium Pass icon.png|16px]] ')
:tag('tr')
:wikitext('[[File:'.. episode.Name ..' episode icon.png|16px]] ' .. episode[1])
:tag('th')
:attr('colspan', 4)
:wikitextIf(episode.Premium == true, '[[File:Premium Pass icon.png|16px]] ')
:wikitext('[[File:'.. episode.Name ..' episode icon.png|16px]] ' .. episode[1])
:done()
:done()
:done()
:done()
:tag('tr')
:tag('tr')
:tag('th')
:tag('th')
:wikitext('Quest')
:wikitext('Quest')
:done()
:tag('th')
:wikitext('Type')
:done()
:tag('th')
:wikitext('Difficulty')
:done()
:tag('th')
:wikitext('Requirements')
:done()
:done()
:done()
:tag('th')
:wikitext('Type')
:done()
:tag('th')
:wikitext('Difficulty')
:done()
:tag('th')
:wikitext('Requirements')
:done()
:done()
if ( episode ) then
-- get all quests for episode --
local quests = mw.smw.ask{
'[[Category:Quests]]',
'[[Name::+]]',
('[[Episode::%s]]'):format( episode.Name ),
'?Quest type',
'?Difficulty',
'?Requirements',
'order=asc',
'sort=Quest type,override_seq,Difficulty'
}
if ( quests ) then
if ( episode ) then
-- get quests for episode --
-- get all quests for episode --
local quests = mw.smw.ask{
for _, quest in ipairs( quests ) do
table
'[[Category:Quests]]',
:tag('tr')
'[[Name::+]]',
('[[Episode::%s]]'):format( episode.Name ),
:tag('td')
:wikitext( quest[1] )
'?Quest type',
:done()
'?Difficulty',
:tag('td')
'?Requirements',
:css {
'order=asc',
'sort=Quest type,override_seq,Difficulty'
['width'] = '50px'
}
}
:wikitext( quest['Quest type'] )
:done()
if ( quests ) then
-- get quests for episode --
:tag('td')
for _, quest in ipairs( quests ) do
:wikitext( parse.difficulty_func( tostring(quest.Difficulty ) ) )
:done()
table
:tag('td')
:tag('tr')
:css {
:tag('td')
['width'] = '55%'
:wikitext( quest[1] )
}
:done()
:tag('div')
:tag('td')
:addClass('lighttable checklist')
:css {
:newline()
['width'] = '50px'
:wikitext( quest.Requirements )
}
:newline()
:wikitext( quest['Quest type'] )
:done()
:tag('td')
:wikitext( parse.difficulty_func( tostring(quest.Difficulty ) ) )
:done()
:tag('td')
:css {
['width'] = '55%'
}
:tag('div')
:addClass('lighttable checklist')
:newline()
:wikitext( quest.Requirements )
:newline()
:done()
:done()
:done()
:done()
:done()
:done()
end
end
end
end
end
end
end
end
table:done()
end
table:done()
return table


return table
end
end



Revision as of 10:33, 15 December 2024

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

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

local p = {}

function p.main(frame)
	local args = frame:getParent().args

	-- get all episodes by episode sequence order --
	local episodes = mw.smw.ask{ 
		'[[Category:Episodes]]',
		('[[Name::%s]]'):format( args.episode or '+' ),
		'[[Episode sequence number::+]]',
		'[[Release Date::+]]',
		'?Name#-',
		'?Premium',
		'order=asc',
		'sort=Episode sequence number',
		'link=none',
		'format=plainlist'
	}
	
	local table = mw.html.create('table')
	if (episodes == nil) then
		table:wikitext("No Quests available for " .. args.episode .. " " .. purge('source-'..mw.uri.anchorEncode(args.episode), '(update)', 'span'))
	else
		table
			:addClass('wikitable quest-table align-center-2 align-center-3 align-left-4')
			:css{
				['width'] = '55%'
			}
			:attr{ cellspacing = '3' }
			
			for _, episode in ipairs(episodes) do
				table
					:tag('tr')
						:tag('th')
						:attr('colspan', 4)
							:wikitextIf(episode.Premium == true, '[[File:Premium Pass icon.png|16px]] ')
							:wikitext('[[File:'.. episode.Name ..' episode icon.png|16px]] ' .. episode[1])
						:done()
					:done()
					:tag('tr')
						:tag('th')
							:wikitext('Quest')
						:done()
						:tag('th')
							:wikitext('Type')
						:done()
						:tag('th')
							:wikitext('Difficulty')
						:done()
						:tag('th')
							:wikitext('Requirements')
						:done()
					:done()
					
					if ( episode ) then
						-- get all quests for episode --
						local quests = mw.smw.ask{ 
							'[[Category:Quests]]',
							'[[Name::+]]',
							('[[Episode::%s]]'):format( episode.Name ),
							'?Quest type',
							'?Difficulty',
							'?Requirements',
							'order=asc',
							'sort=Quest type,override_seq,Difficulty'
						}
						
						if ( quests ) then
							-- get quests for episode --
							for _, quest in ipairs( quests ) do
								table
									:tag('tr')
										:tag('td')
											:wikitext( quest[1] )
										:done()
										:tag('td')
											:css {
												['width'] = '50px'
											}
											:wikitext( quest['Quest type'] )
										:done()
										:tag('td')
											:wikitext( parse.difficulty_func( tostring(quest.Difficulty ) ) )
										:done()
										:tag('td')
											:css {
												['width'] = '55%'
											}
											:tag('div')
												:addClass('lighttable checklist')
												:newline()
												:wikitext( quest.Requirements )
												:newline()
											:done()
										:done()
									:done()
							end
						end
					end
			end
			
			table:done()
	end
	
	return table

end

return p