Module:Average drop value/Sandbox

From RuneRealm Wiki

This is an old revision of this page, as edited by Alex (talk | contribs) at 00:12, 17 October 2024. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Jump to navigation Jump to search

Documentation for this module may be created at Module:Average drop value/Sandbox/doc

local tb = require('Module:Trailblazer Region')._badge

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local orRegions = args['or'] or 'No'
	
	local regions = {'misthalin', 'karamja', 'asgarnia', 'desert', 'fremennik', 'kandarin', 'morytania', 'tirannwn', 'wilderness', 'kourend'}
	
	local ret = mw.html.create('tr')
	mw.log(args[1])
	if args['incompletable'] == 'Yes' then
		ret:tag('th'):wikitext(args[1]):addClass('table-bg-red')
	else ret:tag('th'):wikitext(args[1])
	end
	mw.log(tostring(ret))
	local required = ''
	local auto = ''
	for _, region in ipairs(regions) do
		if args[region] ~= nil then
			if args[region] == 'Yes' then
				if #required ~= 0 then
					required = required .. '&'
				end
				required = required .. region
			elseif args[region] == 'auto' then
				auto = auto .. tb(region)
			else
				ret:tag('td'):wikitext(tb(region) .. ' ' .. args[region])
			end
		end
	end
	if args['incompletable'] == 'Yes' then
		ret:tag('td'):addClass('table-bg-red')
		ret:tag('td'):addClass('table-bg-red')
	else
		ret:tag('td'):wikitext(auto)
		ret:tag('td'):wikitext(tb(required))
	end
	if args['playable'] == 'Yes' then
		if args['incompletable'] == 'Yes' then
			ret:tag('td'):wikitext(string.format('[[File:Yes check.svg|20px|link=|alt=Quest may be played without autocompletion]] Partially playable')):addClass('table-bg-red')
		else ret:tag('td'):wikitext(string.format('[[File:Yes check.svg|20px|link=|alt=Quest may be played without autocompletion]] Fully playable'))
		end
	elseif args['playable'] == 'No' then
		if args['incompletable'] == 'Yes' then
			ret:tag('td'):wikitext(string.format('[[File:X mark.svg|20px|link=|alt=Quest may not be played through]] Not completeable')):addClass('table-bg-red')
		else ret:tag('td'):wikitext(string.format('[[File:X mark.svg|20px|link=|alt=Quest may not be played through]] Autocomplete only'))
		end
	else 
		if args['incompletable'] == 'Yes' then
			ret:tag('td'):wikitext(''):addClass('table-bg-red')
		else ret:tag('td'):wikitext('')
		end
	end
	if args['incompletable'] == 'Yes' then
		ret:tag('td'):wikitext(args['notes'] or ''):addClass('table-bg-red')
	else ret:tag('td'):wikitext(args['notes'] or '')
	end

	return tostring(ret)
end

return p