FANDOM


-- <pre>
local p = {}
 
local addcommas = require( 'Module:Addcommas' )._add
local disdata = mw.loadData('Module:Disassemble/data')
local materials = mw.loadData('Module:Disassemble/mats')
 
-- Smithing dat
p.smithing_items = {
    {name_pre = '', name_post = 'dagger', cat = 'dagger'},
    {name_pre = 'Off-hand ', name_post = 'dagger', cat = 'dagger'},
    {name_pre = '', name_post = 'hatchet', cat = 'hatchet'},
    {name_pre = '', name_post = 'mace', cat = 'mace'},
    {name_pre = 'Off-hand ', name_post = 'mace', cat = 'mace'},
    {name_pre = '', name_post = 'helm', cat = 'melee helm'},
    {name_pre = '', name_post = 'bolts (unf)', name_ite = 1, cat = 'bolt tips', tiers = {2,4,8,13,18,22}, craft_qty=10},
    {name_pre = '', name_post = 'sword', cat = 'sword'},
    {name_pre = 'Off-hand ', name_post = 'sword', cat = 'sword'},
    {name_pre = '', name_post = 'dart tip', cat = 'default', craft_qty=10},
    {name_pre = '', name_post = 'nails', cat = 'default', craft_qty=15},
    {name_pre = '', name_post = 'arrowheads', cat = 'arrowheads', junk = 'half',craft_qty=15},
    {name_pre = '', name_post = 'scimitar', cat = 'scimitar', bars = 2},
    {name_pre = 'Off-hand ', name_post = 'scimitar', cat = 'scimitar', bars = 2},	
    {name_pre = '', name_post = 'pickaxe', cat = 'pickaxe', bars = 2},	
    {name_pre = '', name_post = 'limbs', name_ite = 1, name_fix = 'ite', cat = 'stock', bars = 2},	
    {name_pre = '', name_post = 'longsword', cat = 'longsword', bars = 2},
    {name_pre = 'Off-hand ', name_post = 'longsword', cat = 'longsword', bars = 2},
    {name_pre = '', name_post = 'full helm', cat = 'melee helm', bars = 2},
    {name_pre = '', name_post = 'knife', cat = 'knives',craft_qty=5},	
    {name_pre = 'Off-hand ', name_post = 'knife', cat = 'knives',craft_qty=5},	
    {name_pre = '', name_post = 'throwing axe', cat = 'throwing axes',craft_qty=5},	
    {name_pre = 'Off-hand ', name_post = 'throwing axe', cat = 'throwing axes',craft_qty=5},
    {name_pre = '', name_post = 'sq shield', cat = 'melee shield', bars = 2},
    {name_pre = '', name_post = 'warhammer', cat = 'warhammer', bars = 3},	
    {name_pre = 'Off-hand ', name_post = 'warhammer', cat = 'warhammer', bars = 3},		
    {name_pre = '', name_post = 'battleaxe', cat = 'battleaxe', bars = 3},	
    {name_pre = 'Off-hand ', name_post = 'battleaxe', cat = 'battleaxe', bars = 3},	
    {name_pre = '', name_post = 'chainbody', cat = 'melee body', bars = 3},	
    {name_pre = '', name_post = 'kiteshield', cat = 'melee shield', bars = 3},	
    {name_pre = '', name_post = 'claw', cat = 'claw', bars = 2},	
    {name_pre = 'Off-hand ', name_post = 'claw', cat = 'claw', bars = 2},	
    {name_pre = '', name_post = '2h sword', cat = '2h sword', bars = 3},	
    {name_pre = '', name_post = 'platelegs', cat = 'melee legs', bars = 3},
    {name_pre = '', name_post = 'plateskirt', cat = 'melee legs', bars = 3},
    {name_pre = '', name_post = 'platebody', cat = 'melee body', bars = 5},
    --[[
        TODO: silver/blurite
        and bar specific stuff.. e.g. studs
     --]]
}
 
--
-- Todo: blurite? silver?
-- special items..
 
p.smithing_metals = {
    ['Bronze'] = {id = 0, name = 'Bronze', level = 1},
    ['Iron'] = {id = 1, name = 'Iron', level = 10},
    ['Steel'] = {id = 2, name = 'Steel', level = 20},
    ['Mithril'] = {id = 3, name = 'Mithril', level = 30},
    ['Adamant'] = {id = 4, name = 'Adamant', name_ite = 'Adamantite', level = 40},
    ['Rune'] = {id = 5, name = 'Rune', name_ite = 'Runite', level = 50},
}
 
local junkpast75 = {
	[75] = 4.2, [76] = 3.8, [77] = 3.4, [78] = 3.0, [79] = 2.7,
	[80] = 2.3, [81] = 2.0, [82] = 1.7, [83] = 1.4, [84] = 1.2,
	[85] = 1.0, [86] = 0.8, [87] = 0.6, [88] = 0.4, [89] = 0.3
}
 
 
function p.plink(name,image,article)
	return string.format('[[File:%s.png|link=%s]]&nbsp;[[%s|%s]]', image or name, article or name , article or name, name)
end
 
-- raw value of junk for parsing and properties
function getRawJunk(l)
	if l >= 90 then
		return 0
	end
 
	if l >= 75 then
		return junkpast75[l]
	end
 
	local junk = 100 - 1.1 * l
 
	junk = math.floor((junk) * 1000 + 0.009)/1000
 
	return junk
end
 
function p.addTableHeader(ret)
    ret
		:tag('tr')
			:tag('th'):wikitext('Item'):attr('rowspan',2):done()
			:tag('th'):wikitext('# bars'):attr('rowspan',2):done()
			:tag('th'):wikitext('Base junk %'):attr('rowspan',2):done()
			:tag('th'):wikitext('Components'):attr('colspan',3):done()
			:tag('th'):wikitext('Components/bar'):attr('colspan',2):done()
    		:done()
		:tag('tr')
            :tag('th'):wikitext('Often'):done()
            :tag('th'):wikitext('Sometimes'):done()
            :tag('th'):wikitext('Rarely'):done()
            :tag('th'):wikitext('Reduction 0'):done()
            :tag('th'):wikitext('Reduction 9'):done()   
            :done()
    return ret
end
 
function p.getJunk(tier,item,reduction)
    if item.table == 'default' then
        tier = 1
    elseif item.junk == 'half' then
        tier = math.floor(tier / 2)
    end
 
    mw.log('Tier = ' .. tier .. ' reduction = ' .. reduction)
 
    local junkreduction = {
        [0] = { 1.0},
        [1] = {0.99}, 
        [2] = {0.97}, 
        [3] = {0.95}, 
        [4] = {0.93}, 
        [5] = {0.91}, 
        [6] = {0.88}, 
        [7] = {0.86}, 
        [8] = {0.83}, 
        [9] = {0.8}
	}
 
    local val = getRawJunk(tier) * junkreduction[reduction][1];
    val = math.floor(val*10)/10
    return val
end
 
function p.itemize(val)
    if val == nil then
        return ''    
    end
 
 
    local tbl = mw.text.split(val,'%s*,%s*')
    local val = '\n'
 
    for _, v in pairs(tbl) do
        val = val .. '* ' .. v .. '\n'
    end
 
    return val
end
 
function p.addRow(ret,metal,item)
    local metal_name;
    if item.name_ite then
        metal_name = string.lower(metal.name_ite or metal.name)    
    else
        metal_name = string.lower(metal.name)     
    end
    local name = item.name_pre .. metal_name .. ' ' .. item.name_post
 
    -- imported disassembly data
    local d = disdata[item.cat]
 
    -- How many bars are needed per disassembly action?
    --
    -- = bars * smith_actions
    -- 
    -- smith_actions = items_required / crafted_per_time
    local bars_diss = (item.bars or 1) * ((item.dissassembly_qty or d.itemqty or 1) / (item.craft_qty or 1))
 
    local tier = metal.level
    if item.tiers ~= nil then
        tier = item.tiers[metal.id]
    end
 
 
 
    local base_junk = p.getJunk(tier,item,0)
 
 
    local num_components = d.compqty
 
    local comp_div = 100 * bars_diss
    local min_components = ((100 - p.getJunk(tier,item,0)) * num_components) / comp_div
    local max_components = ((100 - p.getJunk(tier,item,9)) * num_components) / comp_div
 
    ret:tag('tr')
        :tag('td'):wikitext(p.plink(name)):done()
        :tag('td'):wikitext(item.bars or 1):done()
        :tag('td'):wikitext(base_junk):done()
 
        :tag('td'):wikitext(p.itemize(d.often)):done()
        :tag('td'):wikitext(p.itemize(d.sometimes)):done()
        :tag('td'):wikitext(p.itemize(d.rarely)):done()
        :tag('td'):wikitext(math.floor((1000*min_components))/1000):done()
        :tag('td'):wikitext(math.floor((1000*max_components))/1000):done()
    :done()
end
 
function p.showTable(metal) 
    local ret = mw.html.create('table')
                :addClass('wikitable')
                :addClass('align-left-1')
				:css('text-align', 'right')
 
	p.addTableHeader(ret)
	local metal_data = p.smithing_metals[metal]
 
    for _, n in pairs(p.smithing_items) do
        p.addRow(ret,metal_data,n)
    end
 
    return ret:done()
end
 
function p.main(frame)
	local args = frame:getParent().args
	local bar = args.bar or 'Steel'
 
	return p.showTable(bar)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.