Module:Heirloom source

local getArgs = require('Module:Arguments').getArgs local p = {}

local prices = {--{'type', 'vendor', gold, champion's seal, darkmoon prize ticket, honor} ['head']     = {'armor', 'guild',625,0,0,0}, ['neck']     = {'armor', 'open', 700,0,0,0}, ['shoulders'] = {'armor', 'open', 500,25,50,1000}, ['back']     = {'armor', 'guild',625,0,0,0}, ['chest']    = {'armor', 'open', 500,25,50,0}, ['legs']     = {'armor', 'guild',625,0,0,0}, ['trinket']  = {'armor', 'open', 700,35,70,1250}, ['one-hand'] = {'weapon','open', 650,25,50,1000}, ['two-hand'] = {'weapon','open', 750,40,75,1500}, ['ranged']   = {'weapon','open', 750,40,75,1500}, ['off hand'] = {'armor', 'open', 500,25,50,0} }

local upgrades = { --{gold-90, champion's seal-90, darkmoon prize ticket-90, honor-90, gold-100, cs-100, dpt-100, honor-100} ['weapon'] = {1200,65,120,2400,5000,0,0,0}, ['armor'] = {1000,55,100,2000,2000,0,0,0} }

local reqs = { ['head'] = 'honored guild reputation', ['back'] = 'honored guild reputation', ['legs'] = 'a guild that has earned Working Better as a Team' }

local function open(data,pvp) frame = mw.getCurrentFrame s = string.format('%s is sold by the following heirloom vendors:\n* Krom Stoutarm (Ironforge) or Estelle Gendry (Undercity): %s',    mw.title.getCurrentTitle.text,frame:expandTemplate{title='cost', args={data[3]}}) if not pvp and data[4] > 0 then s = s..'\n* Dame Evniki Kapsalis (Argent Tournament Grounds): '.. frame:expandTemplate{title='cost',args={cs=data[4]}} end if not pvp and data[5] > 0 then s = s..'\n* Daenrand Dawncrest (Darkmoon Faire): '.. frame:expandTemplate{title='cost',args={dpt=data[5]}} end if pvp and data[6] > 0 then s = s..'\n* Liliana Emberfrost (Stormwind) or Galra (Orgrimmar): '..frame:expandTemplate{title='cost',args={hp=data[6]}} end return s end

local function guild(cost,slot) frame = mw.getCurrentFrame return string.format('%s is sold by guild vendors for %s and requires %s:\n%s',   mw.title.getCurrentTitle.text, frame:expandTemplate{title='cost',args={cost}}, reqs[slot],    frame:expandTemplate{title=':Guild vendor'}) end

local function upgrade(type) frame = mw.getCurrentFrame data = upgrades[type] suffix = (type == 'armor') and 'Armor Casing' or 'Scabbard'

s = ' The tokens to upgrade this item to be effective from levels 1 to 90 and 1 to 100 are sold by the following vendors: \n' .. '* Ancient Heirloom ' .. suffix .. ' (1-90)\n' .. '** Krom Stoutarm (Ironforge) or Estelle Gendry (Undercity): ' .. frame:expandTemplate{title='cost',args={data[1]}} .. '\n' .. '** Dame Evniki Kapsalis (Argent Tournament Grounds): ' .. frame:expandTemplate{title='cost',args={cs=data[2]}} .. '\n' .. '** Daenrand Dawncrest (Darkmoon Faire): ' .. frame:expandTemplate{title='cost',args={dpt=data[3]}} .. '\n' .. '** Liliana Emberfrost (Stormwind) or Galra (Orgrimmar): ' .. frame:expandTemplate{title='cost',args={hp=data[4]}} .. '\n' .. '* Timeworn Heirloom ' .. suffix ..' (1-100)\n' .. '** Krom Stoutarm (Ironforge) or Estelle Gendry (Undercity): ' .. frame:expandTemplate{title='cost',args={data[5]}} return s end

function p.main(frame) args = getArgs(frame, {wrappers = 'Template:6.1 Heirloom source'}) t = {} slot = string.lower(args.slot or '') data=prices[slot]

if data == nil then return ' Invalid slot. Must be one of: head, neck, shoulders, back, chest, legs, trinket, one-hand, two-hand, ranged, off hand ' end

if data[2]=='open' then t[#t+1] = open(data,args.pvp) else t[#t+1] = guild(data[3],slot) end

t[#t+1] = upgrade(data[1]) return table.concat(t,'\n') end

return p