Module:Sandbox/User:Artoire/1: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
mNo edit summary
mNo edit summary
Line 140: Line 140:
local function _lookup_log_uncached(log)
local function _lookup_log_uncached(log)
local data = mw.smw.ask{
local data = mw.smw.ask{
('[[%s]]'):format(ore),
('[[%s]]'):format(log),
['?Profession Level A'] = '',
['?Profession Level A'] = '',
mainlabel = '-'
mainlabel = '-'
Line 239: Line 239:
:tr()
:tr()
:td{
:td{
'Missing XP for smelting [[' .. ingot.ingot .. ']]; Please [' .. mw.uri.fullUrl(ingot.ingot, 'action=edit&section=1') .. ' edit the page] to add the experience earned (after |exp =)',
'Missing XP for smelting [[' .. ingot.ingot .. ']]; Please [' .. tostring(mw.uri.fullUrl(ingot.ingot, 'action=edit&section=1')) .. ' edit the page] to add the experience earned (after |exp =)',
attr = { colspan = colspan }
attr = { colspan = colspan }
}
}
Line 249: Line 249:
:tr()
:tr()
:td{
:td{
'Missing XP for creating [[' .. weapon.name .. ']]; Please ['.. mw.uri.fullUrl(weapon.name, 'action=edit&section=1') .. ' edit the page] to add the experience earned (after |exp =)',
'Missing XP for creating [[' .. weapon.name .. ']]; Please ['.. tostring(mw.uri.fullUrl(weapon.name, 'action=edit&section=1')) .. ' edit the page] to add the experience earned (after |exp =)',
attr = { colspan = colspan }
attr = { colspan = colspan }
}
}
:done()
:done()
break
else
local xp_per = weapon.xp + ingot.xp * weapon.ingot.quantity
end
local needed = math.ceil(remaining_xp / xp_per)
local xp_per = weapon.xp + ingot.xp * weapon.ingot.quantity
local needed = math.ceil(remaining_xp / xp_per)


local needed_ores = needed * weapon.ingot.quantity
local needed_ores = needed * weapon.ingot.quantity
local row = tbl
local row = tbl
:tag('tr')
:tag('tr')
:td(lookup_ore(ingot.ore).level):done()
:td(lookup_ore(ingot.ore).level):done()
:td{ needed_ores .. '×', css = { ['border-right'] = '0', ['padding-right'] = '0', ['text-align'] = 'right', ['data-sort-value'] = needed_ores } }:done()
:td{ needed_ores .. '×', css = { ['border-right'] = '0', ['padding-right'] = '0', ['text-align'] = 'right', ['data-sort-value'] = needed_ores } }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(ingot.ore, ingot.ore), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border' }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(ingot.ore, ingot.ore), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border' }:done()
:td{ '[[' .. ingot.ore .. ']]', addClass = 'plinkt-link no-border' }:done()
:td{ '[[' .. ingot.ore .. ']]', addClass = 'plinkt-link no-border' }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(ingot.ingot, ingot.ingot), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border', ['data-sort-value'] = needed_ores }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(ingot.ingot, ingot.ingot), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border', ['data-sort-value'] = needed_ores }:done()
:td{ '[[' .. ingot.ingot .. ']]', addClass = 'plinkt-link no-border' }:done()
:td{ '[[' .. ingot.ingot .. ']]', addClass = 'plinkt-link no-border' }:done()


local pole_info
local pole_info
local needed_logs, needed_poles
local needed_logs, needed_poles

if weapon.pole then
needed_poles = needed * weapon.pole.quantity
if chopping_logs then
pole_info = lookup_pole(weapon.pole.name)
needed_logs = math.ceil(needed_poles / 2)
row
:td(lookup_log(pole_info.log).level):done()
:td{ needed_logs .. '×', css = { ['border-right'] = '0', ['padding-right'] = '0', ['text-align'] = 'right' }, attr = { ['data-sort-value'] = needed_logs } }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(pole_info.log, pole.log), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border' }:done()
:td{ '[[' .. pole_info.log .. ']]', addClass = 'plinkt-link no-border' }:done()
end
if chopping_logs or buying_logs then
pole_info = pole_info or lookup_pole(weapon.pole.name)
row
:td(pole_info.level):done()
end


if weapon.pole then
needed_poles = needed * weapon.pole.quantity
if chopping_logs then
pole_info = lookup_pole(weapon.pole.name)
needed_logs = math.ceil(needed_poles / 2)
row
row
:td{ needed_poles .. '×', css = { ['border-right'] = '0', ['padding-right'] = '0', ['text-align'] = 'right' }, attr = { ['data-sort-value'] = needed_poles } }:done()
:td(lookup_log(pole_info.log).level):done()
:td{ needed_logs .. '×', css = { ['border-right'] = '0', ['padding-right'] = '0', ['text-align'] = 'right' }, attr = { ['data-sort-value'] = needed_logs } }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(weapon.pole.name, weapon.pole.name), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border' }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(pole_info.log, pole.log), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border' }:done()
:td{ '[[' .. weapon.pole.name .. ']]', addClass = 'plinkt-link no-border' }:done()
else
:td{ '[[' .. pole_info.log .. ']]', addClass = 'plinkt-link no-border' }:done()
if chopping_logs then
end
row
if chopping_logs or buying_logs then
:na()
pole_info = pole_info or lookup_pole(weapon.pole.name)
:td{ '<small>N/A</small>', addClass = 'table-na', attr = { ['data-sort-value'] = '0', colspan = '3' } }:done()
end
if chopping_logs or buying_logs then
row
:na()
end
row
row
:td{ '<small>N/A</small>', addClass = 'table-na', attr = { ['data-sort-value'] = '0', colspan = '3' } }:done()
:td(pole_info.level):done()
end
end


row
row
:td(weapon.level)
:td{ needed_poles .. '&times;', css = { ['border-right'] = '0', ['padding-right'] = '0', ['text-align'] = 'right' }, attr = { ['data-sort-value'] = needed_poles } }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(weapon.pole.name, weapon.pole.name), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border' }:done()
:td{ needed .. '&times;', css = { ['border-right'] = '0', ['padding-right'] = '0', ['text-align'] = 'right' }, attr = { ['data-sort-value'] = needed } }:done()
:td{ '[[' .. weapon.pole.name .. ']]', addClass = 'plinkt-link no-border' }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(weapon.name, weapon.name), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border' }:done()
:td{ '[[' .. weapon.name .. ']]', addClass = 'plinkt-link no-border' }
else

local cost = needed_ores * lookup_price(ingot.ore)
if chopping_logs then
if chopping_logs then
-- No extra cost
row
elseif buying_logs then
:na()
if needed_logs then
:td{ '<small>N/A</small>', addClass = 'table-na', attr = { ['data-sort-value'] = '0', colspan = '3' } }:done()
cost = cost + needed_logs * lookup_price(pole_info.log)
end
else
if weapon.pole then
cost = cost + needed_poles * lookup_price(weapon.pole.name)
end
end
end
if chopping_logs or buying_logs then
row
:na()
end
row
:td{ '<small>N/A</small>', addClass = 'table-na', attr = { ['data-sort-value'] = '0', colspan = '3' } }:done()
end


row:node(currency._cell(cost, { html = 'yes' }))
row
:td(weapon.level)
:td{ needed .. '&times;', css = { ['border-right'] = '0', ['padding-right'] = '0', ['text-align'] = 'right' }, attr = { ['data-sort-value'] = needed } }:done()
:td{ ('[[File:%s.png|link=%s|30px]]'):format(weapon.name, weapon.name), css = { ['border-left'] = '0', ['padding-left'] = '0' }, addClass = 'plinkt-image no-border' }:done()
:td{ '[[' .. weapon.name .. ']]', addClass = 'plinkt-link no-border' }

local cost = needed_ores * lookup_price(ingot.ore)
if chopping_logs then
-- No extra cost
elseif buying_logs then
if needed_logs then
cost = cost + needed_logs * lookup_price(pole_info.log)
end
else
if weapon.pole then
cost = cost + needed_poles * lookup_price(weapon.pole.name)
end
end
end

row:node(currency._cell(cost, { html = 'yes' }))
end
end