Module:Sandbox/User:Alsang/NodeDescriptionChecker: Difference between revisions
Module:Sandbox/User:Alsang/NodeDescriptionChecker (edit)
Revision as of 18:56, 7 December 2024
, 7 December 2024working for stonemason, need to check all data
No edit summary |
(working for stonemason, need to check all data) |
||
Line 1:
require('strict')
require('Module:Mw.html extension')
local
local param = require( 'Module:Paramtest' )
local currency = require('Module:Currency')
local lang = mw.getContentLanguage()
Line 13 ⟶ 12:
-- returns only directly needed parameter needed for the row,
-- other parameters are determined by subqueries of chained pages
local query = {
--'[[Uses facility::One Handed Range (bonewright)||One Handed Melee Workbench (bonewright)||Two Handed Range Workbench (bonewright)||Two Handed Melee Workbench (bonewright)||Shield Vice
'[[Uses facility::One Handed Ranged Workbench (stonemason)||One Handed Melee Workbench (stonemason)||Two Handed Ranged Workbench (stonemason)||Two Handed Melee Workbench (stonemason)||Shield Work Rock]]', -- stonemason active
--'[[Uses facility::Goblin Forge||Gnome Forge (skill node)]]', -- blacksmith active
'?
'?Profession Level A High =
'?Uses facility = facility',
'? #- = name',
'?Recipe JSON = recipeJSON',
Line 29 ⟶ 24:
'?Activity duration = duration',
'?Value = sell',
'
'limit = 500'
}
local results = mw.smw.ask(query)
results = p.screenResults(results,false)
results = p.formatResults(results)
Line 61 ⟶ 52:
end
return currency._cell(amount, { html = 'yes' })
end
-- Need to split the table into two, lines with crates are passive and lines without are not
function p.screenResults(results,isPassive)
local resultsPassive = {}
local resultsNotPassive = {}
-- iterate through products
for _, item in ipairs(results) do
local hasCrate = item.recipeJSON and string.find(item.recipeJSON,'Crate')
if hasCrate then
table.insert(resultsPassive,item)
else
table.insert(resultsNotPassive,item)
end
end
if isPassive then
return resultsPassive
else
return resultsNotPassive
end
end
-- do calculations and determine strings to go in cells
function p.formatResults(results)
-- iterate through products
for _, item in ipairs(results) do
--
local fullRecipe = search.main(item.name)
item.materials = fullRecipe.materials
item.outputQuantity = fullRecipe.output[1].quantity
item.buy = fullRecipe.buyPrice
-- specific to weapon crafting, where properties are a bit different
-- iterate through materials, keep track of how many materials are needed from each shop
item.poleShopTrips = 0
item.stoneShopTrips = 0
for _, material in ipairs(item.materials) do
-- query which shop sold it, add to running total
local shopNameQuery = '[[:+]][[Sold item::' .. material.name .. ']]|?Sold by #-|mainlabel=' .. material.name
local shopNameResult = mw.smw.ask(shopNameQuery) or {}
local shopName = ''
if shopNameResult[1] and shopNameResult[1]["Sold by"] then
shopName = shopNameResult[1]["Sold by"] or ''
end
if shopName=="Timber Merchant Shop" then
item.poleShopTrips = item.poleShopTrips + material.quantity
elseif shopName=="Poffit's Interesting Rocks" then
item.stoneShopTrips = item.stoneShopTrips + material.quantity
end
end
-- direct values
item.sell = item.sell and item.outputQuantity and item.sell * item.outputQuantity
item.
item.
item.XPPerSpace = item.XPPerStone and item.poleShopTrips and math.floor(item.XP / (item.stoneShopTrips + item.poleShopTrips) * 100) / 100
-- there will be extra time spent buying and selling items, and moving between stations
-- assume make enough trips to buy 24 of each material from each shop, per batch of 24 weapons
local batchSize = 24
-- 120 seconds moving between stations and selling items per 24 made
-- 40 seconds per trip to the pole shop
-- 40 seconds per trip to the stone shop
-- are these results optimal? no. are they approximate? yes
local downtime = 120 + item.poleShopTrips * 40 + item.stoneShopTrips * 40
item.duration = item.duration and item.duration + downtime/batchSize
item.productPerHour = item.duration and 1 / item.duration * 3600
Line 168 ⟶ 136:
-- properties per hour
item.XPPerHour = item.XP and item.productPerHour and math.floor(item.XP * item.productPerHour)
end
Line 181 ⟶ 148:
:tag('th')
:wikitext('[[File:Stonemason small icon.png|15px]] Level')
:done()
:tag('th')
:wikitext('[[File:Hammermage small icon.png|15px]] Levels')
:done()
:tag('th')
:attr{ colspan = '3' }
:wikitext('
:done()
:tag('th')
Line 194 ⟶ 164:
:done()
:tag('th')
:wikitext('XP<br>(per item)')
:done()
:tag('th')
:wikitext('XP<br>(per stome)')
:done()
:tag('th')
:wikitext('XP<br>(per space)')
:done()
:tag('th')
Line 228 ⟶ 192:
:css{ ['text-align'] = 'center' }
:wikitext(item.lvl)
:done()
:ELSE()
:node(unknown_value_cell)
:END()
:IF(item.lvlHigh and item.lvlLow)
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(item.lvlLow)
:wikitext(' – ')
:wikitext(item.lvlHigh)
:done()
:ELSE()
Line 247 ⟶ 221:
:wikitext('[[' .. item.name .. ']]')
:done()
row
:node(currency_cell(item.
:IF(item.XP)
:tag('td')
:wikitext(item.XP and lang:formatNum(tonumber(item.XP)))
:done()
:ELSE()
:node(unknown_value_cell)
:END()
:IF(item.XPPerStone)
:tag('td')
:wikitext(item.XPPerStone and lang:formatNum(tonumber(item.XPPerStone)))
:done()
:ELSE()
:node(unknown_value_cell)
:END()
:IF(item.XPPerSpace)
:tag('td')
:wikitext(item.XPPerSpace and lang:formatNum(tonumber(item.XPPerSpace)))
:done()
:ELSE()
Line 288 ⟶ 263:
:END()
:node(currency_cell(item.
:done()
|