Module:DropsLineTH

-- -- Implements Template:DropsLineTH --

local p = {}

local yesno = require('Module:Yesno') local params = require('Module:Paramtest') local commas = require('Module:Addcommas') local geprice = require('Module:Exchange')._price

local images = { ['agility'] = '', ['attack'] = '', ['constitution'] = '', ['construction'] = '', ['cooking'] = '', ['crafting'] = '', ['defence'] = '', ['divination'] = '', ['dungeoneering'] = '', ['farming'] = '', ['firemaking'] = '', ['fishing'] = '', ['fletching'] = '', ['herblore'] = '', ['hunter'] = '', ['magic'] = '', ['mining'] = '', ['prayer'] = '', ['ranged'] = '', ['runecrafting'] = '', ['slayer'] = '', ['smithing'] = '', ['strength'] = '', ['summoning'] = '', ['thieving'] = '', ['woodcutting'] = '', ['invention'] = 'Invention', -- Change when we have an image ['lucky'] = '', ['extra'] = '', ['extras'] = '', ['cosmetic'] = '', ['cosmetic items'] = '', ['useful'] = '', ['useful items'] = '', ['super rare'] = '', ['prismatic'] = '', ['promotional'] = '' }

local rarity_colors = { ['common'] = 'C5D0DF', ['fairly common'] = 'D5D110', ['uncommon'] = 'CA9402', ['rare'] = 'C10808', ['very rare'] = '8B0093', ['lucky'] = '8B0093' }

function p.make_row(frame) local args = frame:getParent.args local name = args.Name local rarity = args.Rarity local convert = args.convert local quantity = args.Quantity local raritynotes = args.Raritynotes or '' if type( quantity ) == 'string' and not string.match(quantity, '-') then quantity = commas._strip( quantity ) quantity = tonumber( quantity ) end

if params.is_empty(convert) then convert = 'Unknown' else convert = commas._add(convert) end

local category = params.trim(args.category) local catimage = images[string.lower(category)]

if not catimage then catimage = '' end

local rarecolor

if params.has_content(rarity) then rarecolor = rarity_colors[string.lower(rarity)] else rarity = 'Unknown' rarecolor = 'FFFFFF' end

local name_notes = params.trim(args.Namenotes) if not name_notes then name_notes = '' end

local image local gemw = params.trim(ags.gemw)

if params.is_empty(gemw) then gemw = '' end

if string.lower(gemw) == 'no' then -- to prevent redlink image = '' else image = '' -- 	end

local price if string.lower(gemw) == 'no' then price = 'Not sold' else price = frame:expandTemplate{ title = 'GEPrice', args = { name, quantity } } end

return '\n|-\n'.. '| '..image..' || style="text-align:left" | '..name..' '..name_notes..' || '.. commas._add(quantity) .. ' || style="background:#'..rarecolor..'" | '..rarity..' '..raritynotes..' || '..price..' || '..convert..' || '..catimage..'\n|-\n' end

-- -- TODO: Add function for GEP and stuff function qty(quantity,price) -- if no quantity is given, return unknown and the price if not quantity or quantity == 'unknown' then return { 'Unknown', price } end local ret = {} -- recreate the quantity string to ensure consistent formatting local numstr = '' if mw.ustring.find(quantity,'–') then local splitvals = mw.text.split(quantity,'–') local a = tonumber(splitvals[1]) local b = tonumber(splitvals[2]) local smaller,larger if a > b then smaller = b			larger = a		else smaller = a			larger = b		end numstr = commas._add(smaller) .. '–' .. commas._add(larger) else numstr = commas._add(quantity) end

-- If no numbers are found in the string, return unknown if not numstr:find('%d') then return {'Unknown',price} end

ret[1] = numstr local qtys

if high == low then qtys = {['low'] = nil, ['high'] = high} else qtys = {['low'] = low, ['high'] = high} end ret[2] = get_price(price,qtys) return ret end

-- -- -- return p