Module:Rotations/Merchant

From the RuneScape Wiki, the wiki for all things RuneScape
Jump to: navigation, search
Module documentation
This documentation is transcluded from Template:No documentation/doc. [edit] [purge]

This module does not have any documentation. Please consider adding documentation at Module:Rotations/Merchant/doc.

Module:Rotations/Merchant requires Module:Rotations.
Module:Rotations/Merchant requires Module:Currency.
Module:Rotations/Merchant requires Module:Purge.

--[=[
-- Rotation of the [[Travelling Merchant's Shop]]
-- See [[Talk:Travelling Merchant's Shop#History and pattern]] for more info
--]=]
local p = {}
local rotations = require('Module:Rotations')
local coins = require('Module:Currency')._amount
local lang = mw.getContentLanguage()
local purge = require('Module:Purge')._purge

local items = {
	['Uncharted island map (Deep Sea Fishing)'] = {
		name = '[[Uncharted island map (Deep Sea Fishing)|Uncharted island map]]',
		_name = 'uncharted island map',
		cost = 800000,
		quantity = 1,
		use = 'Allows travel to an [[uncharted island]] with the chance of 3-6 special resources at the cost of no supplies<br />In addition, players may also rarely receive a [[Uncharted island map (red)|red uncharted island map]].'
	},
    ['Barrel of bait'] = {
        cost = 50000,
        quantity = 1,
        use = '10% chance to gain an additional catch for 3 minutes.'
    },
    ['Tangled fishbowl'] = {
        cost = 50000,
        quantity = 1,
        use = '5% Fishing experience boost for 3 minutes.'
    },
    ['Broken fishing rod'] = {
        cost = 50000,
        quantity = 1,
        use = '5-10% bonus catch rate for 3-30 minutes.'
    },
    ['Small goebie burial charm'] = {
        cost = 50000,
        quantity = 1,
        use = '50 [[Reputation (Mazcab)|Goebie Reputation]] or 50 [[Teci]]'
    },
    ['Goebie burial charm'] = {
        cost = 100000,
        quantity = 1,
        use = '100 [[Reputation (Mazcab)|Goebie Reputation]] or 100 [[Teci]]'
    },
    ['Menaphite gift offering (small)'] = {
    	_name='small Menaphite gift offering',
        cost = 100000,
        quantity = 1,
        use = 'Variety of rewards, see page'
    },
    ['Menaphite gift offering (medium)'] = {
    	_name='medium Menaphite gift offering',
        cost = 300000,
        quantity = 1,
        use = 'Variety of rewards, see page'
    },
    ['Unstable air rune'] = {
        cost = 250000,
        quantity = 1,
        use = '5,000 [[Runespan#Rewards|Runespan points]]'
    },
    ['Anima crystal'] = {
        cost = 150000,
        quantity = 1,
        use = '500 [[Reputation (Heart of Gielinor)|faction reputation]]'
    },
    ['Slayer VIP Coupon'] = {
    	_name='Slayer VIP coupon',
        cost = 200000,
        quantity = 1,
        use = 'Redeemed for 1-7 [[Slayer VIP ticket]]s'
    },
    ['D&D token (daily)'] = {
    	_name='daily D&D token',
        cost = 250000,
        quantity = 1,
        use = 'One-time use to reset a daily [[D&D]]'
    },
    ['Unfocused damage enhancer'] = {
        cost = 500000,
        quantity = 1,
        use = 'Allows choice of any damage enhancer at the cost of lower charges'
    },
    ['Sacred clay (Deep Sea Fishing)'] = {
    	_name='sacred clay',
        name = '[[Sacred clay (Deep Sea Fishing)|Sacred clay]]',
        cost = 600000,
        quantity = 1,
        use = '50-100 [[Stealing Creation/Rewards#Reward shop|Stealing Creation points]]'
    },
    ['Shattered anima'] = {
        cost = 750000,
        quantity = '500,000-2,000,000',
        use = 'See shop [[Shattered Worlds/Rewards|here]]'
    },
    ['Advanced pulse core'] = {
        cost = 800000,
        quantity = '1-3',
        use = '50% extra experience that does not stack with other sources of bonus experience, up to the equivalent of a Medium prismatic lamp.'
    },
    ['Livid plant (Deep Sea Fishing)'] = {
    	_name='livid plant',
        name = '[[Livid plant (Deep Sea Fishing)|Livid plant]]',
        cost = 1000000,
        quantity = 1,
        use = '10,000 to 40,000 [[produce points]]'
    },
    ['Gift for the Reaper'] = {
    	_name='gift for the Reaper',
        cost = 1250000,
        quantity = 1,
        use = '20 [[Reaper points]]'
    },
    ['Silverhawk down'] = {
        cost = 1500000,
        quantity = '50-100',
        use = 'See [[silverhawk down]] for experience calculator'
    },
    ['Large goebie burial charm'] = {
        cost = 150000,
        quantity = 1,
        use = '150 [[Reputation (Mazcab)|Goebie Reputation]] or 150 [[Teci]]'
    },
    ['Message in a bottle (Deep Sea Fishing)'] = {
    	_name='message in a bottle',
        name  = '[[Message in a bottle (Deep Sea Fishing)|Message in a bottle]]',
        cost = 200000,
        quantity = 1,
        use = 'One time choice between three [[Deep Sea Fishing]] boosts'
    },
    ['Dragonkin lamp'] = {
        cost = 250000,
        quantity = 1,
        use = 'Rewards a set amount of experience and a 1/100 chance to obtain [[Effy]]'
    },
    ['Dungeoneering Wildcard'] = {
    	_name='Dungeoneering Wildcard',
        cost = 400000,
        quantity = '1-3',
        use = 'Consuming the card inside [[Daemonheim]] rewards 50% extra experience and [[dungeoneering token|token]]s'
    },
    ['Menaphite gift offering (large)'] = {
    	_name='large Menaphite gift offering',
        cost = 500000,
        quantity = 1,
        use = 'Variety of rewards, see page'
    },
    ['Taijitu'] = {
        cost = 800000,
        quantity = '3-5',
        use = 'Secondary currency used for the [[Waiko Reward Shop]].'
    },
    ['D&D token (weekly)'] = {
    	_name='weekly D&D token',
        cost = 400000,
        quantity = 1,
        use = 'One-time use to reset a weekly [[D&D]]'
    },
    ['D&D token (monthly)'] = {
    	_name='monthly D&D token',
        cost = 1000000,
        quantity = 1,
        use = 'One-time use to reset a monthly [[D&D]]'
    },
    ['Starved ancient effigy'] = {
        cost = 1000000,
        quantity = 1,
        use = 'Rewards a set amount of experience in multiple skills and a 1/100 chance to obtain [[Effy]]'
    },
    ['Harmonic dust'] = {
        cost = 2000000,
        quantity = '500-1000',
        use = 'Used for creating [[crystal tool]]s'
    },
    ['Crystal triskelion'] = {
        cost = 2000000,
        quantity = 1,
        use = 'Deposited in a cliff face south of [[Rellekka]] to obtain a [[clue scroll (elite)]] and variety of other rewards'
    },
    ['Deathtouched dart'] = {
        cost = 5000000,
        quantity = 1,
        use = 'Insta-kill majority of all NPCs'
    },
    ['Unfocused reward enhancer'] = {
        cost = 10000000,
        quantity = 1,
        use = 'Allows choice of any reward enhancer at the cost of lower charges'
    }
}

-- should really make the above table into an array and use those as IDs but whatever
-- DO NOT MOVE THESE AROUND
local itemIDs = {
	'Barrel of bait', 'Tangled fishbowl', 'Broken fishing rod', 'Message in a bottle (Deep Sea Fishing)',		-- 4
	'Small goebie burial charm', 'Goebie burial charm', 'Large goebie burial charm',							-- 7
	'Menaphite gift offering (small)', 'Menaphite gift offering (medium)', 'Menaphite gift offering (large)',	-- 10
	'D&D token (daily)', 'D&D token (weekly)', 'D&D token (monthly)',											-- 13
	'Unstable air rune', 'Anima crystal', 'Taijitu', 'Gift for the Reaper', 'Slayer VIP Coupon',				-- 18
	'Shattered anima', 'Livid plant (Deep Sea Fishing)', 'Sacred clay (Deep Sea Fishing)',						-- 21
	'Unfocused damage enhancer', 'Unfocused reward enhancer',													-- 23
	'Silverhawk down', 'Advanced pulse core', 'Dungeoneering Wildcard',											-- 26
	'Dragonkin lamp', 'Starved ancient effigy', 'Harmonic dust',												-- 29
	'Crystal triskelion', 'Deathtouched dart'																	-- 31
}
-- DO NOT MOVE THESE AROUND
local slotA_rotation = {
	18, 22, 17, 2, 15, 8, 5, 9, 19, 5, 11, 18, 21, 25, 2, 14, 25, 17, 2, 3,
	8, 5, 9, 21, 5, 11, 21, 19, 25, 17, 14, 3, 17, 2, 3, 5, 5, 9, 21, 19,
	11, 18,	19, 24, 2, 14, 3, 1, 2, 3, 5, 1, 9, 21, 8, 20, 21, 19, 24, 14,
	14, 3, 1, 17, 3, 5, 17, 6, 21, 19, 20, 14, 19, 24, 14, 18, 3, 1, 17, 6,
	5, 1, 6, 19, 8,	20, 14, 21, 24, 14, 18, 22, 1, 17, 15, 8, 17, 6, 19, 5,
	20, 14, 21, 25, 14, 18, 25, 17, 17, 6, 8, 5, 6, 19, 5, 11, 14, 21, 25, 17
}
-- DO NOT MOVE THESE AROUND
local slotB_rotation = {
	18, 22, 17, 8, 14, 3, 6, 19, 21, 24, 2, 5, 18, 22, 3, 8, 8, 20, 14, 17,
	21, 25, 22, 5, 5, 11, 21, 2, 19, 24, 25, 1, 1, 9, 19, 14, 8, 11, 24, 17,
	17, 6, 8, 18, 1, 9, 20, 14, 2, 3, 5, 21, 17, 6, 9, 18, 18, 22, 1, 8,
	2, 15, 6, 21, 21, 25, 2, 5, 14, 3, 15, 19, 19, 24, 14, 1, 18, 25, 3, 8,
	8, 20, 18, 17, 19, 24, 22, 1, 5, 9, 21, 2, 8, 20, 24, 17, 17, 6, 19, 18,
	5, 11, 20, 2, 2, 15, 5, 21, 1, 9, 11, 14, 14, 3, 1, 19, 17, 15, 9, 18
}
-- DO NOT MOVE THESE AROUND
local slotC_rotation = {
    1, 1, 2, 1, 3, 4, 3, 1, 5, 6, 6, 6, 5, 7, 8, 5, 7, 9, 1, 2,
	4, 4, 1, 4, 6, 10, 4, 11, 7, 2, 5, 5, 9, 12, 2, 9, 4, 12, 4, 12
}
-- DO NOT MOVE THESE AROUND
local slotC_itemMap = {
    'Dragonkin lamp', 'D&D token (weekly)', 'Deathtouched dart',
	'Menaphite gift offering (large)', 'Starved ancient effigy', 'Large goebie burial charm',
	'Crystal triskelion', 'Taijitu', 'Message in a bottle (Deep Sea Fishing)',
	'Unfocused reward enhancer', 'Dungeoneering Wildcard',	'Harmonic dust',
	'D&D token (monthly)'
}
-- DO NOT MOVE THESE AROUND
local slotC_initial = {
	1, 8, 3, 7, 4, 11, 10, 13, 12, 2, 9, 5, 6
}

function slotAB(rot, offsetFromNow)
	local rotation = rotations.rotation_days(1, #rot, 39+(offsetFromNow or 0))
	local name = itemIDs[rot[rotation]]
	local item = items[name]
	return name, item
end
function p.slotA(offsetFromNow)
	return slotAB(slotA_rotation, offsetFromNow)
end
function p.slotB(offsetFromNow)
	return slotAB(slotB_rotation, offsetFromNow)
end

function p.slotC(offsetFromNow)
	local rotation = rotations.rotation_days(1, #slotC_rotation, -1+(offsetFromNow or 0))
	local current = rotations.rotation_days(40, 13, -1+(offsetFromNow or 0))
	
	local currentItemId = slotC_rotation[rotation]
	local outputItemId = ((slotC_initial[currentItemId] + current) % #slotC_itemMap) + 1
	local itemName = slotC_itemMap[outputItemId]
	local itemDetails = items[itemName]
	
	return itemName, itemDetails
end

function p.api(frame)
	local args = frame:getParent().args
	return p._api(args.offset, args.format)
end
function p._api(offset, format)
	offset = tonumber(offset or 0) or 0
	local a, a_d = p.slotA(offset)
	local b, b_d = p.slotB(offset)
	local c, c_d = p.slotC(offset)
	
	if format == 'simple' then
		return string.format('@%s¦%s¦%[email protected]', a, b ,c)
	end
	if format == 'json' then
		local jsonret = {}
		jsonret['timestamp'] = os.time()
		a_d.name = a
		b_d.name = b
		c_d.name = c
		jsonret['items'] = {a_d, b_d, c_d}
		return mw.text.jsonEncode(jsonret)
	end
	local ret = mw.html.create('div')
	ret	:tag('span')
			:addClass('slotA')
				:tag('span'):addClass('name'):wikitext(a):done()
				:tag('span'):addClass('cost'):wikitext(a_d.cost):done()
				:tag('span'):addClass('quantity'):wikitext(a_d.quantity):done()
				:tag('span'):addClass('use'):wikitext(a_d.use):done()
			:done()
			:addClass('slotB')
				:tag('span'):addClass('name'):wikitext(b):done()
				:tag('span'):addClass('cost'):wikitext(b_d.cost):done()
				:tag('span'):addClass('quantity'):wikitext(b_d.quantity):done()
				:tag('span'):addClass('use'):wikitext(b_d.use):done()
			:done()
			:addClass('slotC')
				:tag('span'):addClass('name'):wikitext(c):done()
				:tag('span'):addClass('cost'):wikitext(c_d.cost):done()
				:tag('span'):addClass('quantity'):wikitext(c_d.quantity):done()
				:tag('span'):addClass('use'):wikitext(c_d.use):done()
			:done()
	return ret	
end

function makeFullRow(name, details)
	local tr = mw.html.create('tr')
	local page = details.name or string.format('[[%s]]', name)
	tr	:tag('td')
			:wikitext(string.format('[[File:%s.png|link=%s]]', name, name))
			:addClass('inventory-image')
		:done()
		:tag('td')
			:wikitext(page)
		:done()
		:tag('td')
			:wikitext(coins(details.cost, 'coins'))
		:done()
		:tag('td')
			:wikitext(details.quantity)
		:done()
		:tag('td')
			:wikitext(details.use)
		:done()
	return tr
end

function p.today(frame)
	local t = mw.html.create('table')
	t	:addClass('wikitable align-center-1 align-center-4')
		:tag('tr')
			:tag('th')
				:wikitext('Item')
				:attr('colspan', 2)
			:done()
			:tag('th')
				:wikitext('Cost')
			:done()
			:tag('th')
				:wikitext('Quantity')
			:done()
			:tag('th')
				:wikitext('Use')
			:done()
	t	:node(makeFullRow('Uncharted island map (Deep Sea Fishing)', items['Uncharted island map (Deep Sea Fishing)']))
		:node(makeFullRow(p.slotA(0)))
		:node(makeFullRow(p.slotB(0)))
		:node(makeFullRow(p.slotC(0)))
	local cd = mw.html.create('span')
	cd	:addClass('countdown')
		:attr('data-end', 'stop')
		:tag('span')
			:addClass('countdowndate')
			:wikitext(lang:formatDate('F d Y') .. ' 23:59 UTC')
	return string.format("''This is the stock for %s.'' <sup>%s</sup><br />Valid for %s\n%s", lang:formatDate('[[j F]] [[Y]]'), tostring(purge()), tostring(cd), tostring(t))
end

function makeShortRow(offset, onlyitem)
	function plink(img, page)
		local link = page or string.format('[[%s]]', img)
		return string.format('[[File:%s.png|link=%s]]&nbsp;%s', img, img, link)
	end
	local a_n, a_d = p.slotA(offset)
	local b_n, b_d = p.slotB(offset)
	local c_n, c_d = p.slotC(offset)
	local classA, classB, classC = nil,nil,nil
	if onlyitem then
		local foundonlyitem = false
		local highlightclass = 'table-bg-green'
		if a_n == onlyitem then
			classA = highlightclass
			foundonlyitem = true
		end
		if b_n == onlyitem then
			classB = highlightclass
			foundonlyitem = true
		end
		if c_n == onlyitem then
			classC = highlightclass
			foundonlyitem = true
		end
		if not foundonlyitem then
			return nil
		end
	end
	local tr = mw.html.create('tr')
	tr	:tag('td')
			:wikitext(lang:formatDate('j F Y', string.format('+%s day', offset)))
		:done()
		:tag('td')
			:wikitext(plink(a_n, a_d.name))
			:addClass(classA)
			:addClass('inventory-image')
		:done()
		:tag('td')
			:wikitext(plink(b_n, b_d.name))
			:addClass(classB)
			:addClass('inventory-image')
		:done()
		:tag('td')
			:wikitext(plink(c_n, c_d.name))
			:addClass(classC)
			:addClass('inventory-image')
		:done()
	return tr
end

function p.future(frame)
	local args = frame:getParent().args
	local s = args.start or args[1] or 0
	local e = args['end'] or args[2] or 5
	return p._future(s,e)
end
function p._future(startOffset, endOffset)
	-- enforce numbers
	startOffset = tonumber(startOffset or 0) or 0
	endOffset = tonumber(endOffset or 5) or 5
	-- switch around if start/end mixed
	if startOffset > endOffset then
		startOffset, endOffset = endOffset, startOffset
	end
	function parseOffsetsToString()
		local start_s = math.abs(startOffset) > 1 and 's' or ''
		local end_s = math.abs(endOffset) > 1 and 's' or ''
		if startOffset == endOffset then
			if startOffset > 0 then return string.format('%s day%s after today', startOffset, start_s)
			elseif startOffset < 0 then return string.format('%s day%s before today', startOffset*-1, start_s)
			elseif startOffset == 0 then return 'today' end
		else
			local s = ''
			if startOffset > 0 then s = string.format('%s%s day%s after today', s, startOffset, start_s)
			elseif startOffset < 0 then s = string.format('%s%s day%s before today', s, startOffset*-1, start_s)
			elseif startOffset == 0 then s = string.format('%stoday', s) end
			s = string.format('%s to ', s)
			if endOffset > 0 then s = string.format('%s%s day%s after today', s, endOffset, end_s)
			elseif endOffset < 0 then s = string.format('%s%s day%s before today', s, endOffset*-1, end_s)
			elseif endOffset == 0 then s = string.format('%stoday', s) end
			return s
		end
		return '(error: start and/or end not numbers)'
	end
	
	local t = mw.html.create('table')
	t	:addClass('wikitable sticky-header')
		:tag('tr')
			:tag('th')
				:wikitext('Date')
			:done()
			:tag('th')
				:wikitext('Slot A')
			:done()
			:tag('th')
				:wikitext('Slot B')
			:done()
			:tag('th')
				:wikitext('Slot C')
			:done()
	for i=startOffset,endOffset,1 do
		t:node(makeShortRow(i))
	end
	return string.format("This table is the stock for %s (%s)<sup>%s</sup>\n%s", parseOffsetsToString(), lang:formatDate('j F Y'), purge(), tostring(t))
end

function p.orderAB()
	local t = mw.html.create('table')
	t	:addClass('wikitable sticky-header mw-collapsible mw-collapsed align-center-1 align-center-4 align-center-7')
		:tag('tr')
			:tag('th')
				:attr('colspan', 11)
				:wikitext('Slot A and B cycles')
			:done()
		:done()
		:tag('tr')
			:tag('th'):wikitext('Day'):done()
			:tag('th'):wikitext('Slot A'):done()
			:tag('th'):wikitext('Slot B'):done()
			:tag('th'):attr('rowspan', 41):wikitext('&nbsp;'):done()
			:tag('th'):wikitext('Day'):done()
			:tag('th'):wikitext('Slot A'):done()
			:tag('th'):wikitext('Slot B'):done()
			:tag('th'):attr('rowspan', 41):wikitext('&nbsp;'):done()
			:tag('th'):wikitext('Day'):done()
			:tag('th'):wikitext('Slot A'):done()
			:tag('th'):wikitext('Slot B'):done()
			
	for i=1,40,1 do
		t	:tag('tr')
				:tag('td'):wikitext(i):done()
				:tag('td'):wikitext(itemIDs[slotA_rotation[i]]):done()
				:tag('td'):wikitext(itemIDs[slotB_rotation[i]]):done()
				:tag('td'):wikitext(i+40):done()
				:tag('td'):wikitext(itemIDs[slotA_rotation[i+40]]):done()
				:tag('td'):wikitext(itemIDs[slotB_rotation[i+40]]):done()
				:tag('td'):wikitext(i+80):done()
				:tag('td'):wikitext(itemIDs[slotA_rotation[i+80]]):done()
				:tag('td'):wikitext(itemIDs[slotB_rotation[i+80]]):done()
				
	end
	return t
end

function p.orderC()
	local t = mw.html.create('table')
	t	:addClass('wikitable mw-collapsible align-center-1 align-center-2 align-center-3 align-center-4')
		:tag('tr')
			:tag('th'):attr('colspan', 5):wikitext('Item order (IDs)'):done()
		:done()
		:tag('tr')
			:tag('th'):wikitext('Day'):done()
			:tag('th'):wikitext('Item order ID'):done()
			:tag('th'):attr('rowspan', 21):wikitext('&nbsp;'):done()
			:tag('th'):wikitext('Day'):done()
			:tag('th'):wikitext('Item order ID'):done()
	for i=1,20,1 do
		t	:tag('tr')
				:tag('td'):wikitext(i):done()
				:tag('td'):wikitext(slotC_rotation[i]):done()
				:tag('td'):wikitext(i+20):done()
				:tag('td'):wikitext(slotC_rotation[i+20]):done()
					
	end
	return t
end

function p.itemsC()
	local t = mw.html.create('table')
	t	:addClass('wikitable mw-collapsible align-center-1')
		:tag('tr')
			:tag('th'):attr('colspan', 2):wikitext('Item map'):done()
		:done()
		:tag('tr')
			:tag('th'):wikitext('Item map ID'):done()
			:tag('th'):wikitext('Item'):done()
	for i=1,#slotC_itemMap,1 do
		t	:tag('tr')
				:tag('td'):wikitext(i):done()
				:tag('td'):wikitext(slotC_itemMap[i]):done()
					
	end
	return t
end

function p.initialC()
	local t = mw.html.create('table')
	t	:addClass('wikitable mw-collapsible align-center-1 align-center-2')
		:tag('tr')
			:tag('th'):attr('colspan', 3):wikitext('Item initial order'):done()
		:done()
		:tag('tr')
			:tag('th'):wikitext('Item order ID'):done()
			:tag('th'):wikitext('Item map ID'):done()
			:tag('th'):wikitext('Item map name'):done()
	for i=1,#slotC_itemMap,1 do
		t	:tag('tr')
				:tag('td'):wikitext(i):done()
				:tag('td'):wikitext(slotC_initial[i]):done()
				:tag('td'):wikitext(slotC_itemMap[slotC_initial[i]]):done()
					
	end
	return t
end

function p.currentC()
	local current = rotations.rotation_days(40, 13, -1)
	local t = mw.html.create('table')
	t	:addClass('wikitable mw-collapsible align-center-1 align-center-2')
		:tag('tr')
			:tag('th'):attr('colspan', 3):wikitext('Item current order'):done()
		:done()
		:tag('tr')
			:tag('th'):wikitext('Item order ID'):done()
			:tag('th'):wikitext('Item map ID'):done()
			:tag('th'):wikitext('Item map name'):done()
	for i=1,#slotC_itemMap,1 do
		local j = ((slotC_initial[i] + current) % 13) + 1
		t	:tag('tr')
				:tag('td'):wikitext(i):done()
				:tag('td'):wikitext(j):done()
				:tag('td'):wikitext(slotC_itemMap[j]):done()
					
	end
	return tostring(t)
end

function p.listItems()
	local slotAB_list = {
		'Barrel of bait', 'Tangled fishbowl', 'Broken fishing rod',
		'Small goebie burial charm', 'Goebie burial charm',	'Menaphite gift offering (small)',
		'Menaphite gift offering (medium)',	'Unstable air rune', 'Anima crystal',
		'Slayer VIP Coupon', 'D&D token (daily)', 'Unfocused damage enhancer',
		'Sacred clay (Deep Sea Fishing)', 'Shattered anima', 'Advanced pulse core',
		'Livid plant (Deep Sea Fishing)', 'Gift for the Reaper', 'Silverhawk down'
	}
	
	local slotC_list = {
		'Large goebie burial charm', 'Message in a bottle (Deep Sea Fishing)', 'Dragonkin lamp',
		'Dungeoneering Wildcard', 'Menaphite gift offering (large)', 'Taijitu',
		'D&D token (weekly)', 'D&D token (monthly)', 'Starved ancient effigy',
		'Harmonic dust', 'Crystal triskelion', 'Deathtouched dart',
		'Unfocused reward enhancer'
	}
	
	local t = mw.html.create('table')
	t	:addClass('wikitable align-center-1 align-center-4')
		:tag('tr')
			:tag('th'):attr('colspan', 5):wikitext('Slot 1 (always)'):done()
		:done()
		:tag('tr')
			:tag('th'):attr('colspan', 2):wikitext('Item'):done()
			:tag('th'):wikitext('Cost'):done()
			:tag('th'):wikitext('Quantity'):done()
			:tag('th'):wikitext('Use'):done()
		:done()
		:node(makeFullRow('Uncharted island map (Deep Sea Fishing)', items['Uncharted island map (Deep Sea Fishing)']))
		:tag('tr')
			:tag('th'):attr('colspan', 5):wikitext('Slots 2 and 3'):done()
		:done()
		:tag('tr')
			:tag('th'):attr('colspan', 2):wikitext('Item'):done()
			:tag('th'):wikitext('Cost'):done()
			:tag('th'):wikitext('Quantity'):done()
			:tag('th'):wikitext('Use'):done()
		:done()
		
	for i,v in ipairs(slotAB_list) do
		t:node(makeFullRow(v, items[v]))
	end
		
	t	:tag('tr')
			:tag('th'):attr('colspan', 5):wikitext('Slot 4'):done()
		:done()
		:tag('tr')
			:tag('th'):attr('colspan', 2):wikitext('Item'):done()
			:tag('th'):wikitext('Cost'):done()
			:tag('th'):wikitext('Quantity'):done()
			:tag('th'):wikitext('Use'):done()
		:done()
	
	for i,v in ipairs(slotC_list) do
		t:node(makeFullRow(v, items[v]))
	end
	return t
end

function p.nextItem(frame)
	local args = frame:getParent().args
	local item = args.item
	if not item then
		item = mw.title.getCurrentTitle().text
	end
	return p._nextItem(item, tonumber(args.number), tonumber(args.limit))
end

function p._nextItem(item, n, dayslimit)
	local list = {
		['Barrel of bait'] = 'ab',
		['Tangled fishbowl'] = 'ab',
		['Broken fishing rod'] = 'ab',
		['Small goebie burial charm'] = 'ab',
		['Goebie burial charm'] = 'ab',
		['Menaphite gift offering (small)'] = 'ab',
		['Menaphite gift offering (medium)'] = 'ab',
		['Unstable air rune'] = 'ab',
		['Anima crystal'] = 'ab',
		['Slayer VIP Coupon'] = 'ab',
		['D&D token (daily)'] = 'ab',
		['Unfocused damage enhancer'] = 'ab',
		['Sacred clay (Deep Sea Fishing)'] = 'ab',
		['Shattered anima'] = 'ab',
		['Advanced pulse core'] = 'ab',
		['Livid plant (Deep Sea Fishing)'] = 'ab',
		['Gift for the Reaper'] = 'ab',
		['Silverhawk down'] = 'ab',

		['Large goebie burial charm'] = 'c',
		['Message in a bottle (Deep Sea Fishing)'] = 'c',
		['Dragonkin lamp'] = 'c',
		['Dungeoneering Wildcard'] = 'c',
		['Menaphite gift offering (large)'] = 'c',
		['Taijitu'] = 'c',
		['D&D token (weekly)'] = 'c',
		['D&D token (monthly)'] = 'c',
		['Starved ancient effigy'] = 'c',
		['Harmonic dust'] = 'c',
		['Crystal triskelion'] = 'c',
		['Deathtouched dart'] = 'c',
		['Unfocused reward enhancer'] = 'c'
	}
	if not list[item] then
		return "Unrecognised item ''"..item.."''. Please enter the item name exactly."
	end
	if not n then
		n = 5
	end
	if not dayslimit then
		dayslimit = 200
	end
	
	local t = mw.html.create('table')
	t	:addClass('wikitable sticky-header')
		:tag('tr')
			:tag('th')
				:wikitext('Date')
			:done()
			:tag('th')
				:wikitext('Slot A')
			:done()
			:tag('th')
				:wikitext('Slot B')
			:done()
			:tag('th')
				:wikitext('Slot C')
			:done()
	
	local d = 0
	local count = 0
	while count < n and d < dayslimit do
		local r = makeShortRow(d, item)
		if r then
			t:node(r)
			count = count + 1
		end
		d = d + 1
	end
	local simpleitem = item:lower()
	local iteminfo = items[item]
	if iteminfo._name then
		simpleitem = iteminfo._name
	end
	local intro = string.format('This table shows the next %s dates<sup>%s</sup> on which %s is available in the [[Travelling Merchant\'s Shop]], where it can be purchased for %s.', count, tostring(purge()), simpleitem, coins(iteminfo.cost, 'nocoinsc'))
	
	return intro .. '\n' .. tostring(t)
end

function p.todayIcons(frame)
	function makeIconRow(offset)
		local m_n, m_d = 'Uncharted island map (Deep Sea Fishing)', items['Uncharted island map (Deep Sea Fishing)']
		local a_n, a_d = p.slotA(offset)
		local b_n, b_d = p.slotB(offset)
		local c_n, c_d = p.slotC(offset)
		local tr = mw.html.create('tr')
		tr	:tag('td')
				:wikitext(string.format('[[File:%s.png|link=%s]]', m_n, m_n))
				:addClass('inventory-image')
			:done()
			:tag('td')
				:wikitext(string.format('[[File:%s.png|link=%s]]', a_n, a_n))
				:addClass('inventory-image')
			:done()
			:tag('td')
				:wikitext(string.format('[[File:%s.png|link=%s]]', b_n, b_n))
				:addClass('inventory-image')
			:done()
			:tag('td')
				:wikitext(string.format('[[File:%s.png|link=%s]]', c_n, c_n))
				:addClass('inventory-image')
			:done()
		return tr
	end
	local offset = 0
	local t = mw.html.create('table')
	t	:addClass('wikitable align-center-1 align-center-4')
		:tag('tr')
			:tag('th')
				:wikitext(string.format('Stock for %s',lang:formatDate('[[j F]] [[Y]]', string.format('+%s day', offset))))
				:attr('colspan', 4)
			:done()
	t	:node(makeIconRow(offset))
	return string.format(tostring(t))
end

return p