Módulo:Rotação

De RuneScape Wiki
Ir para: navegação, pesquisa
Documentação do módulo
Esta documentação é transcluída de Predefinição:Sem documentação/doc. [editar] [atualizar]
Este módulo não possui nenhuma documentação. Por favor, considere adicionar uma documentação em Módulo:Rotação/doc. [editar]
Módulo:Rotação requer Módulo:Purge.
Módulo:Rotação é solicitado por Módulo:Rotação/Mercador.

--[[ <nowiki>
Various functions for activities that have time based rotations
--]]
local p = {}

local purge = require('Módulo:Purge')._purge

local seconds_in_day = 24 * 60 * 60
local seconds_in_minute = 60

local _on_ = 'table-bg-green'
local _off_ = 'table-bg-grey'

local yesno = {
	[true] = _on_,
	[false] = _off_
}

local unit_seconds_from_name = {
	minute = seconds_in_minute,
	day = seconds_in_day
}

local lang = mw.language.new('pt-br')
--[[
Adds a table row with a purge button to the table passed
Also gives the table an anchor id so that clicking purge will return readers to the table
--]]
function p.add_purge(builder,cols)
	local page_title = mw.title.getCurrentTitle().fullText
	local url = tostring(mw.uri.fullUrl(page_title..'#reload','action=purge'))
	builder:attr('id','reload')
	builder:tag('tr')
			:tag('td')
				:attr({ colspan = cols or 1 })
				:wikitext(purge('reload'))
			:done()
		:done()
end

function p.add_purge2(tabl, td)
	local page_title = mw.title.getCurrentTitle().fullText
	local url = tostring(mw.uri.fullUrl(page_title..'#reload','action=purge'))
	tabl:attr('id','reload')
	td:wikitext('&nbsp;'..purge('reload'))
	:done()
end

--[[
Returns the plural of the word
--]]
function p.plural(word, n, plural)
	if n == 1 then
		return word
	else
		return plural or (word .. 's')
	end
end

--[[

--]]
function p.on_off(on_time, total_time, offset, unit_seconds)
	local units_after_utc = math.floor(os.time() / unit_seconds)
	local units_into_start = (units_after_utc + offset) % total_time

	local on = units_into_start < on_time

	local units_until_change
	if on then
		units_until_change = on_time - units_into_start
	else
		units_until_change = total_time - units_into_start
	end

	return on, units_until_change
end

--[[
Returns a number that can be used to identify the rotation based on:
* The number of days per rotation
* The number of rotations available
* The offset of days such that Tuesday 1 January 1970 + offset would be the starting day for rotation 1 (this should be between 0 and 6)

Also returns a second value that determines how many days until the next rotation
--]]
function p.rotation_days(interval, rotation_count, offset)
	local days_after_utc = math.floor(os.time() / seconds_in_day)
	local days_into_period = (days_after_utc + offset) % (interval * rotation_count)

	local rotation = math.floor(days_into_period / interval) + 1
	local days_until_next_rotation = interval - days_into_period % interval

	return rotation, days_until_next_rotation
end

--[[
Returns a number that can be used to identify the rotation based on:
* The number of minutes per rotation
* The number of rotations available
* The offset of minutes such that Tuesday 1 January 1970 + offset would be the starting time for rotation 1

Also returns a second value that determines how many minutes until the next rotation
--]]
function p.rotation_minutes(interval, rotation_count, offset)
	local minutes_after_utc = math.floor(os.time() / seconds_in_minute)
	local minutes_into_period = (minutes_after_utc + offset) % (interval * rotation_count)

	local rotation = math.floor(minutes_into_period / interval) + 1
	local minutes_until_next_rotation = interval - minutes_into_period % interval

	return rotation, minutes_until_next_rotation
end

--[[

--]]
function p.simple_on_off(on_time, total_time, offset, unit_name)
	local unit_seconds = unit_seconds_from_name[unit_name]

	local on, change_time = p.on_off(on_time, total_time, offset, unit_seconds)

	local ret_table = mw.html.create('table')
				:addClass('wikitable')
				:css({ ['text-align'] = 'center',
					float = 'right' })
				:tag('tr')
					:tag('td')
						:wikitext('Tempo até ' .. (on and 'end' or 'start') .. ': ' .. change_time .. ' ' .. p.plural(unit_name, change_time))
						:addClass(yesno[on])
					:done()
				:done()

	p.add_purge(ret_table)
	return ret_table
end

local function date_of(i_rot, interval, curr_rot, next_in, total_rots)
	local s = os.time() + seconds_in_day * (next_in + interval * ((i_rot - curr_rot - 1) % total_rots) )
	if i_rot==curr_rot then
		return 'Agora!'
	else
		return lang:formatDate('j "de" M', '@' .. s, nil)
	end
end

local function date_of_full(i_rot, interval, curr_rot, next_in, total_rots)
	local s = os.time() + seconds_in_day * (next_in + interval * ((i_rot - curr_rot - 1)) )
	return lang:formatDate('j "de" F Y', '@' .. s, nil)
end

--[[

--]]
function p.simple_table(rotation_names, interval, offset, dated)
	local rotation, next = p.rotation_days(interval, #rotation_names, offset)
	local align = 'center'

	if dated then
		align = 'left'
		pad = '0.5em'
	end

	local ret_table = mw.html.create('table')
				:addClass('wikitable')
				:css({ ['text-align'] = align,
					margin = '3px',
					float = 'right' })
				:tag('caption')
					:wikitext('Rotação atual')
				:done()
	local td
	for i, v in ipairs(rotation_names) do
		td = ret_table:tag('tr'):tag('td')
		td			:addClass(yesno[i==rotation])
					:wikitext(v)
					:done()
				:done()
			:done()
		if dated then
			td:css('padding-left', '0.5em')
				:tag('span')
				:css({ ['float'] = 'right',
					['text-align'] = 'right',
					['font-size'] = '80%',
					['margin-left'] = '5px' })
				:wikitext(date_of(i, interval, rotation, next, #rotation_names))
		end
	end
	td = ret_table:tag('tr'):tag('td')
	td			:css('text-align', 'center')
				:wikitext("'''Próximo: "..next..' '..p.plural('dia', next).."'''")
			:done()
		:done()
	--if dated then
		p.add_purge2(ret_table, td)
	--else
	--	p.add_purge(ret_table)
	--end
	return ret_table
end

--[[

--]]
function p.simple_table_minutes(rotation_names, interval, offset)
	local rotation, next = p.rotation_minutes(interval, #rotation_names, offset)
	local align = 'center'

	local ret_table = mw.html.create('table')
				:addClass('wikitable')
				:css({ ['text-align'] = align,
					margin = '3px',
					float = 'right' })
				:tag('caption')
					:wikitext('Rotação atual')
				:done()
	local td
	for i, v in ipairs(rotation_names) do
		td = ret_table:tag('tr'):tag('td')
		td			:addClass(yesno[i==rotation])
					:wikitext(v)
					:done()
				:done()
			:done()
	end
	td = ret_table:tag('tr'):tag('td')
	td			:css('text-align', 'center')
				:wikitext("'''Próximo: "..next..' '..p.plural('minuto', next).."'''")
			:done()
		:done()
	p.add_purge2(ret_table, td)
	return ret_table
end

--[=======================================================[
--						ON/OFF
--]=======================================================]

--[==========[
--	Corvo de priffdinas
--]==========]
function p.raven()
	local on, change_time = p.on_off(1, 13, 7, seconds_in_day)

	local text
	if on then
		text = '<b>Existe atualmente um corvo em Prifddinas, veja abaixo!</b>'
	else
		local last = 13 - change_time

		local date_format = "%e %B %Y"
		local last_date = lang:formatDate('j "de" F "de" Y', os.date(date_format, os.time() - last * seconds_in_day))
		local next_date = lang:formatDate('j "de" F "de" Y', os.date(date_format, os.time() + change_time * seconds_in_day))

		text = 'O último corvo apareceu há <b>' .. last .. ' ' .. p.plural('dia', last) .. ', em ' .. last_date .. '</b>. O próximo irá aparecer em <b>' .. change_time .. ' ' .. p.plural('dia', change_time) .. ', em ' .. next_date .. '</b>. '
	end

	return text .. purge()
end

--[==========[
--	Castaways
--]==========]
function p.castaways(frame)
    local args = frame:getParent().args
    
    local bottle = args.bottle
    if (bottle == nil) then
        bottle = 1
    end
    
    local offset = 7
    
    local hidewarning = args.hidewarning
    if (hidewarning == nil) then
        hidewarning = 'no'
    end
    
    local starttext = args.starttext
    if (starttext == nil) then
        starttext = 'Esta mensagem numa garrafa'
    end
    
    if (bottle == "3") then
        offset = 6
    end
    if (bottle == "5") then
        offset = 5
    end
    if (bottle == "6") then
        offset = 3
    end
    if (bottle == "7") then
        offset = 8
    end
    if (bottle == "9") then
        offset = 9
    end
    if (bottle == "10") then
        offset = 5
    end
    
	local on, change_time = p.on_off(1, bottle, offset, seconds_in_day)

	local text
	if on then
		text = starttext..' está atualmente <span style="font-weight:bold;">visível</span>. '
	else
		local last = bottle - change_time

		local date_format = "%e %B"
		local last_date = lang:formatDate('j "de" F "de" Y', os.date(date_format, os.time() - last * seconds_in_day))
		local next_date = lang:formatDate('j "de" F "de" Y', os.date(date_format, os.time() + change_time * seconds_in_day))

		text = starttext..' ficou visível pela última vez há <span style="font-weight:bold;">' .. last .. ' ' .. p.plural('dia', last) .. '</span> em ' .. last_date .. '. Irá aparecer novamente em <span style="font-weight:bold;">' .. change_time .. ' ' .. p.plural('dia', change_time) .. '</span> em ' .. next_date .. '. '
	end

    text = text ..  purge()

    if (hidewarning ~= 'yes') then
        text = text .. ' Once a message in a bottle is found and when a player has walked near its spawn location when it was visible it will always be visible, unless the message in the bottle or its treasure map is in the player\'s bank or inventory.' 
    end

	return text
end

--[=============[
--	Sinkholes
--]=============]
function p.sinkholes()
	return p.simple_on_off(15, 60, 30, 'minuto')
end

--[================[
--	Guthixian Cache
--]================]
function p.guthix_cache()
	local on, change_time = p.on_off(10, 60, 0, seconds_in_minute)	--For the Hourly event
	local on2, change_time2 = p.on_off(10, 3*60, 0, seconds_in_minute)	--For the Guthixian Boost
	
	--Copied from p.simple_on_off; modified
	local ret_table = mw.html.create('table')
				:addClass('wikitable')
				:css('float','right')
				:css('clear','right')
				:tag('tr')
				    :tag('th')
				        :wikitext('Tempo até ' .. (on and 'end' or 'start'))
				        :css('text-align','right')
				    :done()
					:tag('td')
						:wikitext(change_time .. ' ' .. p.plural('minuto', change_time))
						:addClass(yesno[on])
					:done()
				:done()
				:tag('tr')
				    :tag('th')
				        :wikitext('Tempo até os bônus ' .. (on2 and 'end' or 'start'))
				        :css('text-align','right')
				    :done()
					:tag('td')
						:wikitext(change_time2 .. ' ' .. p.plural('minuto', change_time2))
						:addClass(yesno[on2])
					:done()
				:done()

	p.add_purge(ret_table,2)
	return ret_table
end

--[==================[
--	Big chinchompa
--]==================]
function p.big_chinchompa()
	return p.simple_on_off(20, 60, 30, 'minuto')
end

--[================[
--	Supply run
--]================]
function p.supply_run()
	return p.simple_on_off(25, 12 * 60, 0, 'minuto')
end

--[=======================================================[
--						  Cycles
--]=======================================================]

--[=======================[
--	Minigame spotlight
--]=======================]

--modified version of p.simple_table
local function spotlight_table(rotation_names, interval, offset)
	local rotation, next = p.rotation_days(interval, #rotation_names, offset)
	local align = 'left'
	local pad = '0.5em'

	local ret_table = mw.html.create('table')
				:addClass('wikitable')
				:css({ ['text-align'] = align,
					margin = '3px',
					float = 'right' })
				:tag('caption')
					:wikitext('Rotação atual')
				:done()
	local td
	local starti = 0
	for i,v in ipairs(rotation_names) do
		if date_of(i, interval, rotation, next, #rotation_names) == 'Now!' then
			starti = i-1
			break
		end
	end

	local j = 0
	local i, v
	while j < #rotation_names do
		i = ((starti + j) % #rotation_names)+1
		v = '[['..rotation_names[i]..']]'
		td = ret_table:tag('tr'):tag('td')
		td			:addClass(yesno[i==rotation])
					:wikitext(v)
					:done()
				:done()
			:done()
		td:css('padding-left', '0.5em')
			:tag('span')
			:css({ ['float'] = 'right',
				['text-align'] = 'right',
				['font-size'] = '80%',
				['margin-left'] = '5px' })
			:wikitext(date_of(i, interval, rotation, next, #rotation_names))
		j = j + 1
	end
	td = ret_table:tag('tr'):tag('td')
	td		  :css('text-align', 'center')
				:wikitext("'''Próximo: "..next..' '..p.plural('dia', next).."'''")
			:done()
		:done()
		p.add_purge2(ret_table, td)
	return ret_table
end

local function get_spotlight_list()
	return {
		'Controle de Praga',
		'Guerra das Almas',
		'Punho de Guthix',
		'Assalto Bárbaro',
		'Conquista',
		'Traineira de Pesca',
		'O Grande Projeto Orbe',
		'Fábrica de Pó Luminoso',
		'Guerra das Cidadelas',
		'Criações Profanas',
		'Festival de Socos de Repolhos',
		'Pega Ladrão',
		'Mobilização dos Exércitos',
		'Assalto Bárbaro',
		'Conquista',
		'Punho de Guthix',
		'Guerra das Cidadelas',
		'Controle de Praga',
		'Guerra das Almas',
		'Traineira de Pesca',
		'O Grande Projeto Orbe',
		'Fábrica de Pó Luminoso',
		'Criações Profanas',
		'Festival de Socos de Repolhos',
		'Pega Ladrão',
		'Me dá um Refresco',
		'Guerra das Cidadelas'
	}
end

function p.spotlight()
	return spotlight_table(get_spotlight_list(), 3, -49) -- -49 to force same order as news post
end

local function to_row(val)
	return '|-\n!Próximo spotlight\n|'..val..'&nbsp;'..purge() --use wikicode until infoboxes are modulised
end

--find the date of the next spotlighted minigame
--returns '' if minigame is not found in the list
--returns a row with the date of the next spotlight, or 'Now!'
function p.next_spotlight(frame)
	local interval, offset = 3, -49
	local rotations = get_spotlight_list()
	local name = frame:getParent().args[1]
	local rotation, next_in = p.rotation_days(interval, #rotations, offset)
	local pos = {}
	local found = false

	for i,v in ipairs(rotations) do
		if name == v then
			pos[i] = '0'
			found = true
		end
	end
	if not found then
		return ''
	end

	for i,v in pairs(pos) do
		if i == rotation then
			return to_row("'''Agora!'''")
		end
		pos[i] = os.time() + seconds_in_day * (next_in + interval * ((tonumber(i) - rotation - 1) % #rotations) )
	end

	local next_rot = os.time() + seconds_in_day*365
	for i,v in pairs(pos) do
		if next_rot > v then
			next_rot = v
		end
	end

	return to_row(lang:formatDate('j "de" F', '@' .. next_rot, nil))
end

--[============[
--	Vorago
--]============]
function p.vorago()
	local rotations = {
		'Detonação do teto',
		'Scopulus',
		'Vitalis',
		'Bomba verde',
		'Divisão de equipe',
		'O Fim',
	}

	return p.simple_table(rotations, 7, -6, false) -- -6 to force "the end" to be last
end
--[==========[
--	Rots
--]==========]
-- Array borrowed from http://www.pso-clan.com/rotations.js
function p.rots()
	local b = {
			A = 'Ahrim',
			D = 'Dharok',
			G = 'Guthan',
			K = 'Karil',
			T = 'Torag',
			V = 'Verac'
	}
	local rotations = {
		{{b.D,b.T,b.V},{b.K,b.A,b.G}},
		{{b.K,b.T,b.G},{b.A,b.D,b.V}},
		{{b.K,b.G,b.V},{b.A,b.T,b.D}},
		{{b.G,b.T,b.V},{b.K,b.A,b.D}},
		{{b.K,b.T,b.V},{b.A,b.G,b.D}},
		{{b.A,b.G,b.D},{b.K,b.T,b.V}},
		{{b.K,b.A,b.D},{b.G,b.T,b.V}},
		{{b.A,b.T,b.D},{b.K,b.G,b.V}},
		{{b.A,b.D,b.V},{b.K,b.T,b.G}},
		{{b.K,b.A,b.G},{b.T,b.D,b.V}},
		{{b.A,b.T,b.G},{b.K,b.D,b.V}},
		{{b.A,b.G,b.V},{b.K,b.T,b.D}},
		{{b.K,b.A,b.T},{b.G,b.D,b.V}},
		{{b.K,b.A,b.V},{b.D,b.T,b.G}},
		{{b.A,b.T,b.V},{b.K,b.D,b.G}},
		{{b.K,b.D,b.G},{b.A,b.T,b.V}},
		{{b.D,b.T,b.G},{b.K,b.A,b.V}},
		{{b.G,b.D,b.V},{b.K,b.A,b.T}},
		{{b.K,b.T,b.D},{b.A,b.G,b.V}},
		{{b.K,b.D,b.V},{b.A,b.T,b.G}}
	}
	local days_after_utc = math.floor(os.time() / seconds_in_day)
	local rotation = (days_after_utc % 20) + 1
	rotation = rotations[rotation]
	local today = lang:formatDate('j "de" F "de" Y', os.date("%e %B %Y"))
	local ret = mw.html.create('table')
				:addClass('wikitable')
				:css({ ['text-align'] = 'center',
					float = 'right' })
				:tag('caption')
					:wikitext(today)
				:done()
				:tag('tr')
					:tag('th')
						:wikitext('Oeste')
					:done()
					:tag('th')
						:attr('rowspan','4')
					:done()
					:tag('th')
						:wikitext('Leste')
					:done()
				:done()
	local s1,s2 = unpack(rotation)
	for i=1,3 do
		ret:tag('tr')
			:tag('td')
				:wikitext(s1[i])
			:done()
			:tag('td')
				:wikitext(s2[i])
			:done()

	end
	p.add_purge(ret,3)
	return ret
end

--[==========[
--	TH D&D
--]==========]
function p.th_dnd()
	local rotations = {
		'[[Árvore Sinistra]]',
		'[[Estrela Cadente]]',
		'[[Esconde-esconde de Pinguim]]',
		'[[Circo]]'
	}

	return p.simple_table(rotations, 7, 1, false)
end

--[========================[
--	Circus city template
--]========================]
function p.circus(frame)
	local args = frame:getParent().args
	local disp = mw.text.trim( string.lower(args[1] or '') )
	if disp == 'list' then
		return p.circus_city_list()
	elseif disp == 'city' then
		return p.circus_city_name()
	else
		return p.circus_city_table()
	end
end

--[======================[
--	Circus city (both)
--	Simple return vals
--]======================]
function p.circus_city()
	local rotations = {
		{ name = '[[Forte dos Gnomos Arborícolas]] - sul da entrada; perto do portão',
			coord = '2444,3381',
			short = 'Forte dos Gnomos'
		},
		{ name = '[[Aldeia dos Videntes]]',
			coord = '2689,3475',
			short = 'Aldeia dos Videntes'
		},
		{ name = '[[Catherby]]',
			coord = '2791,3456',
			short = 'Catherby'
		},
		{ name = '[[Taverley]]',
			coord = '2891,3470',
			short = 'Taverley'
		},
		{ name = '[[Fronteiriça]]',
			coord = '3118,3504',
			short = 'Fronteiriça'
		},
		{ name = '[[Faladore]]',
			coord = '3027,3349',
			short = 'Faladore'
		},
		{ name = '[[Rimmington]]',
			coord = '2950,3234',
			short = 'Rimmington'
		},
		{ name = '[[Vila Draynor]]',
			coord = '3098,3213',
			short = 'Draynor'
		},
		{ name = '[[Al Kharid]]',
			coord = '3313,3206',
			short = 'Al Kharid'
		},
		{ name = '[[Lumbridge]]',
			coord = '3210,3276',
			short = 'Lumbridge'
		},
		{ name = '[[Varrock]] - sudeste do Depósito de Madeira',
			coord = '3300,3467',
			short = 'Depósito de Madeira'
		},
		{ name = '[[Varrock]] - norte da casa de [[Gertrudes]]',
			coord = '3144,3424',
			short = 'Gertrudes'
		}
	}
	local rotation,next = p.rotation_days(7,#rotations,1)
	return rotations,rotation,next
end

--[======================[
--	Circus city (both)
--	Pretty table
--]======================]
function p.circus_city_table()
	local rotations,rot,next = p.circus_city()
	local map = '{{Mapa|mtype=square|' .. rotations[rot].coord .. '|width=250|height=250}}'
	local loc = rotations[rot].name
	local ret = mw.html.create('table')
			:addClass('wikitable')
			:css('text-align','center')
			:tag('tr')
				:tag('th')
					:wikitext('Localização atual:')
				:done()
				:tag('td')
					:attr('rowspan','13')
					:wikitext(mw.getCurrentFrame():preprocess(map))
				:done()
			:done()
	for i, v in ipairs(rotations) do
		ret:tag('tr')
			:tag('td')
				:addClass(yesno[i==rot])
				:wikitext(v.short)
			:done()
		:done()
	end
	ret	:tag('tr')
			:tag('td')
				:attr('colspan','2')
				:wikitext(loc)
			:done()
		:done()
	local td = ret:tag('tr'):tag('td')
	td			:attr('colspan','2')
					:wikitext("'''Dias até ao próximo: "..next.."'''")
				:done()
			:done()
		:done()
	p.add_purge2(ret, td)
	return ret
end

--[====================[
--	Circus city name
--]====================]
function p.circus_city_name()
	local rotations,rot = p.circus_city()
	return rotations[rot].name
end

--[======================[
--	Circus city list
--	List of maplinks
--]======================]
function p.circus_city_list()
	local ul = mw.html.create('ul')
	local rotations = p.circus_city()
	local frame = mw.getCurrentFrame()
	
	for _, v in ipairs(rotations) do
		local maplink = '{{Maplink|mtype=square|' .. v.coord .. '|text=' .. string.gsub(v.name, '[\][]', '') .. '}}'
		ul:tag('li'):wikitext(frame:preprocess(maplink))
	end
	
	return ul
end	

--[===========[
--	Araxxor
--]===========]
function p.araxxor()
	local rax_rotations = {
		'Servos',
		'Ácido',
		'Escuridão'
	}

	local rotation, days_to_next = p.rotation_days(4, #rax_rotations, 3)

	function is_open(path)
		if path == rotation then
			return false
		else
			return true
		end
	end

	function add_body(path, tb)
		local open = is_open(path)
		local td = tb:tag('td')
		if open then
			td:wikitext('Aberto'):addClass(_on_)
		else
			td:wikitext('Fechado'):addClass(_off_)
		end
	end

	local t = mw.html.create('table'):addClass('wikitable'):css('text-align','center')
	local th = t:tag('tr')
	local tb = t:tag('tr')
	for i=1,3 do
		th:tag('th'):wikitext('Caminho ' .. i .. ' (' .. rax_rotations[i] .. ')')
		add_body(i, tb)
	end

	local td = t:tag('th'):attr('colspan', '3'):wikitext('Dias até a próxima rotação: ' .. days_to_next)

	local cocoon
	if is_open(1) and is_open(2) then
		cocoon = 'Eu morri coberto de aranhas ácidas.'
	elseif is_open(1) and is_open(3) then
		cocoon = 'Eu morri na escuridao, coberto de aranhas.'
	elseif is_open(2) and is_open(3) then
		cocoon = 'Eu morri numa piscina de ácido escura.'
	end
	t:tag('tr'):tag('td'):attr('colspan','3'):css('font-style','italic'):wikitext(cocoon)
	p.add_purge2(t,td)
	return t
end

--[============[
--	Icxan
--]============]
function p.Icxan()
	local rotations = {
	    'Covil do Grutoverme (Porto Sarim)',
		'Torre dos Magos',
		'Nardah',
		'Torre dos Exterminadores (Canifis)',
		'Serraria (Varrock)',
		'Solar de Draynor',
		'Pico do Lobo Branco',
		'Caverna de Skavid',
		'Oo\'glog',
		'Faladore',
	}

	return p.simple_table_minutes(rotations, 60, 180) -- -120 in order to fix the time offst.
end

--[============[
-- Jewels of the Elid
--]============]
function p.jewels(frame)
	local rot = {
		-- A = Apmeken amethyst
		-- S = Scabarite crystal
		-- X = None
		'X', 'X', 'X', 'X', 'A', 'A', 'S', 'S', 'X', 'X', 
		'X', 'X', 'A', 'X', 'S', 'A', 'X', 'X', 'X', 'X', 
		'A', 'X', 'S', 'A', 'X', 'S', 'X', 'X', 'A', 'X', 
		'S', 'A', 'X', 'S', 'X', 'X', 'X', 'X', 'S', 'A', 
		'X', 'S', 'X', 'X', 'X', 'X', 'A', 'A', 'S', 'S', 
		'X', 'X', 'X', 'X', 'A', 'X', 'S', 'S', 'X', 'X', 
		'X', 'X', 'A', 'X', 'S', 'A', 'X', 'X', 'X', 'X', 
		'A', 'X', 'S', 'A', 'X', 'X', 'X', 'X', 'A', 'X', 
		'S', 'A', 'X', 'S', 'X', 'X', 'X', 'X', 'A', 'A', 
		'X', 'S', 'X', 'X', 'X', 'X', 'A', 'A', 'S', 'S', 
		'X', 'X', 'X', 'X', 'A', 'X', 'S', 'S', 'X', 'X', 
		'X', 'X', 'A', 'X', 'S', 'S', 'X', 'X', 'X', 'X', 
		'A', 'X', 'S', 'A', 'X', 'X', 'X', 'X', 'X', 'X', 
		'S', 'A', 'X', 'S', 'X', 'X', 'X', 'X', 'A', 'A', 
		'X', 'S', 'X', 'X', 'X', 'X', 'A', 'A', 'X', 'S', 
		'X', 'X', 'X', 'X', 'A', 'A', 'S', 'S', 'X', 'X', 
		'X', 'X', 'A', 'X', 'S', 'S', 'X', 'X', 'X', 'X', 
		'A', 'X', 'S', 'A', 'X', 'S', 'X', 'X', 'X', 'X', 
		'S', 'A', 'X', 'S', 'X', 'X', 'X', 'X', 'S', 'A', 
		'X', 'S', 'X', 'X', 'X', 'X', 'A', 'A', 'X', 'S',
	}
	local currFormat = {
		X = 'None available today',
		A = '[[File:Ametista de Apmeken detalhe.png|50x50px|frameless|link=Ametista de Apmeken]]<br />[[Ametista de Apmeken]]',
		S = '[[File:Cristal de Scabaras detalhe.png|50x50px|frameless|link=Cristal de Scabaras]]<br />[[Cristal de Scabaras]]',
	}
	local numtodisp = tonumber(frame:getParent().args.count)
	if not numtodisp then
		numtodisp = 5
	end
	local count = #rot
	local now = p.rotation_days(1,count,-122)
	local ret = { A = {}, S = {}}
	local j = now
	while #ret.A < numtodisp or #ret.S < numtodisp do
		j = j + 1
		local i = ((j-1) % count) + 1
		local gem = rot[i]
		if gem ~= 'X' then
			table.insert(ret[gem], date_of_full(j, 1, now, 1, count))
		end
	end

	local t = mw.html.create('table')
	t	:addClass('wikitable')
		:css('text-align', 'center')
		:tag('caption')
			:wikitext('Jewels of the Elid rotation')
		:done()
	local td = t	:tag('tr')
			:tag('th')
				:wikitext("Today's date")
			:done()
			:tag('td')
				:wikitext(lang:formatDate('j F Y'))
	t	:tag('tr')
			:tag('th')
				:wikitext('Currently available')
			:done()
			:tag('td')
				:wikitext(currFormat[rot[now]])
			:done()
		:done()
		:tag('tr')
			:tag('th')
				:attr('colspan',2)
				:wikitext('Next '..numtodisp..' available')
			:done()
		:done()
		:tag('tr')
			:tag('th')
				:wikitext('[[File:Ametista de Apmeken.png|link=Ametista de Apmeken]] [[Ametista de Apmeken]]')
			:done()
			:tag('th')
				:wikitext('[[File:Cristal de Scabaras.png|link=Cristal de Scabaras]] [[Cristal de Scabaras]]')
			:done()
		:done()
	p.add_purge2(t, td)
	for i=1,numtodisp do
		t:tag('tr')
			:tag('td')
				:wikitext(ret.A[i])
			:done()
			:tag('td')
				:wikitext(ret.S[i])
			:done()
	end
	return t
end

--[============[
--	Elite Dungeon spotlight
--]============]
function p.EDSpotlight()
	local rotations = {
	    'Templo de Aminishi',
	    'Dragonkin Laboratory',
	    'The Shadow Reef',
	    'Templo de Aminishi', --loop twice to show next spotlight of each
	    'Dragonkin Laboratory',
	    'The Shadow Reef'
	}

	return spotlight_table(rotations, 1, 0) -- -120 in order to fix the time offst.
end

return p