Module:Sandbox/User:Artoire/1: Difference between revisions
m
no edit summary
mNo edit summary |
mNo edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 3:
current_xp = 24,
target_xp = 37,
ingot = '
profession = 'Stonemason', -- 'Bonewright'/'Stonemason'/'Blacksmith'
ore_buy = 'true',
pole_buy = 'none', -- 'none'/'logs'/'pole'
})
]]
Line 10 ⟶ 13:
require('Module:Mw.html extension')
local xp = require('Module:Experience')
local currency = require('Module:Currency')
local lang = mw.language.getContentLanguage()
local
local function lookup_ingots(profession)
if _ingots[profession] then
return _ingots[profession]
end
_ingots[profession] = {
recipes = {},
order = {}
}
for _, result in ipairs(mw.smw.ask{
({
Blacksmith = '[[Uses facility::Goblin Smelter||Gnome Smelter]]',
Stonemason = '[[Uses facility::T.E.A. Machine]]',
Bonewright = '[[Uses facility::B.R.E.W.S. Vat]]'
})[profession],
['?Recipe JSON'] = '',
mainlabel = '-',
Line 30 ⟶ 38:
result = mw.text.jsonDecode(result[1])
local ingot = result.output[1].name
xp = result.xp,
facility = result.facility,
Line 37 ⟶ 45:
level = result.level
}
table.insert(
end
return
end
local function lookup_weapons(profession)
local ingots = lookup_ingots(profession)
local weapons = {}
for _, result in ipairs(mw.smw.ask{
({
Blacksmith = '[[Uses facility::Goblin Forge||Gnome Forge]]',
Stonemason = '[[Category:Stonemason]][[Category:Pages with recipes]][[Uses facility::!T.E.A. Machine]]',
Bonewright = '[[Category:Bonewright]][[Category:Pages with recipes]][[Uses facility::!B.R.E.W.S. Vat]]'
})[profession],
['?Recipe JSON'] = '',
mainlabel = '-',
Line 56 ⟶ 66:
local lvl = result['Profession Level A']
result = mw.text.jsonDecode(result[1])
if not result.passive and result.profession == profession then
local
local pole
if ingots.recipes[material.name] then
assert(not ingot
ingot = material
else
assert(not pole
pole = material
end
end
weapons[ingot.name] = weapons[ingot.name] or {}
table.insert(weapons[ingot.name], {
facility = result.facility,
level = result.level,
ingot = ingot,
pole = pole,
name = result.output[1].name,
xp = result.xp
})
end
end
return weapons
Line 93 ⟶ 105:
end
local _lookup_price_cache = {}
local function lookup_price(item)
return
end
Line 119 ⟶ 131:
end
local _lookup_pole_cache = {}
local function lookup_pole(pole)
return
end
Line 136 ⟶ 148:
end
local _lookup_ore_cache = {}
local function lookup_ore(ore)
return
end
Line 153 ⟶ 165:
end
local _lookup_log_cache = {}
local function lookup_log(log)
return
end
Line 163 ⟶ 175:
local p = {}
function p.ingots(frame)
return table.concat(lookup_ingots(frame.args.profession).order, ',')
end
Line 170 ⟶ 182:
return p._main(frame:getParent().args)
end
function p._main(args)
local profession = args.profession
local current_xp = tonumber(args.current_xp) or 0
local current_lvl
Line 201 ⟶ 213:
buying_poles = not (buying_logs or chopping_logs)
local ingot = lookup_ingots(profession).recipes[args.ingot]
local result = mw.html.create()
Line 224 ⟶ 236:
tbl
:tag('tr')
:th(skillclickpic(
Blacksmith = 'Miner',
Stonemason = 'Miner',
Bonewright = 'Gatherer'
})[profession])):done()
:th{ ({
Blacksmith = 'Ore',
Stonemason = 'Rock',
Bonewright = 'Bone'
})[profession], attr = { colspan = '3' } }:done()
:th{ ({
Blacksmith = 'Ingot',
Stonemason = 'Etched',
Bonewright = 'Brewed'
})[profession], attr = { colspan = '2' } }:done()
:IF(chopping_logs)
:th(skillclickpic('Woodcutter')):done()
Line 235 ⟶ 259:
:END()
:th{ 'Pole', attr = { colspan = '3' } }:done()
:th(skillclickpic(
:th{ 'Product', attr = { colspan = '3' } }:done()
:th{ 'Cost', attr = { colspan = '10' } }:done()
:done()
for _, weapon in ipairs(lookup_weapons(profession)[ingot.ingot]) do
if not ingot.xp then
tbl
:tr()
:td{
'Missing XP for
attr = { colspan = colspan }
}
Line 319 ⟶ 343:
local cost = needed_ores * lookup_price(ingot.ore)[buying_ores and 'buy' or 'sell']
if chopping_logs then
if needed_logs then
cost = cost + needed_logs * lookup_price(pole_info.log).sell
end
elseif buying_logs then
if needed_logs then
cost = cost + needed_logs * lookup_price(pole_info.log).buy
end
else
if weapon.pole then
cost = cost + needed_poles * lookup_price(weapon.pole.name).buy
end
end
row:node(currency._cell(cost, { html = 'yes' }))
end
end
|