Module:Sandbox/User:Alsang/NodeDescriptionChecker: Difference between revisions
Module:Sandbox/User:Alsang/NodeDescriptionChecker (edit)
Revision as of 22:26, 3 December 2024
, 3 December 2024all needed functions, now need to decide how to shrink it
m (downtime for leatherworker) |
(all needed functions, now need to decide how to shrink it) |
||
Line 4:
local param = require( 'Module:Paramtest' )
local currency = require('Module:Currency')
local discount = require('Module:MerchantHideDiscount')
local lang = mw.getContentLanguage()
Line 69 ⟶ 70:
-- do calculations and determine strings to go in cells
function p.formatResults(results)
local discountList = discount.main()
-- iterate through
for _, item in ipairs(results) do
Line 79 ⟶ 82:
-- some fields are easy to work out
item.outputQuantity = 1
item.
item.intermediates = {}
item.buy = 0
Line 94 ⟶ 97:
local Materials = recipe._getTrueRawMaterials(unpackJSON.materials)
if next(Materials) ~= nil then
item.
item.intermediates = Materials.intermediateMaterials
end
-- iterate through
item.buy = 0
item.buyDiscount = 0
for _,
--shamelessley lifted from Module:Products
local shopPriceQuery = '[[:+]][[Sold item::' ..
local shopPriceResult = mw.smw.ask(shopPriceQuery) or {}
local shopPrice = 0
Line 113 ⟶ 117:
end
item.buy = item.buy and item.buy + shopPrice *
--with the merchant discount, buy price is sell price
local shopPriceQuery = '[[:+]][[Sold item::' .. material.name .. ']]|?Shop sell price|mainlabel=' .. material.name
local shopPriceResult = mw.smw.ask(shopPriceQuery) or {}
local shopPrice = 0
if shopPriceResult[1] and shopPriceResult[1]["Shop sell price"] then
shopPrice = tonumber(shopPriceResult[1]["Shop sell price"]) or 0
else
item.buyDiscount = nil
end
item.buyDiscount = item.buyDiscount and item.buyDiscount + shopPrice * material.quantity
end
Line 161 ⟶ 178:
item.sell = item.sell and item.outputQuantity and item.sell * item.outputQuantity
item.profit = item.sell and item.buy and item.sell - item.buy
item.profitDiscount = item.sell and item.buyDiscount and item.sell - item.buyDiscount
item.profitPerXP = item.profit and item.XP and math.floor(item.profit / item.XP * 100) / 100
item.profitPerXPDiscount = item.profitDiscount and item.XP and math.floor(item.profitDiscount / item.XP * 100) / 100
local hideName = string.gsub(item.name,'Leather','Hide')
item.discountLevel = discountList[hideName]
-- a lot of downtime in leatherworker
Line 168 ⟶ 189:
local downtime = 100
item.duration = item.duration and item.duration + downtime/batchSize
item.
-- properties per hour
item.XPPerHour = item.XP and item.
item.profitPerHour = item.profit and item.
item.profitPerHourDiscount = item.profitDiscount and item.productPerHour and math.floor(item.profitDiscount * item.productPerHour)
end
Line 188 ⟶ 210:
:tag('th')
:attr{ colspan = '3' }
:wikitext('
:done()
:tag('th')
:wikitext('
:done()
:tag('th')
Line 210 ⟶ 232:
:done()
:tag('th')
:wikitext('[[File:Merchant_small_icon.png|18px]] level for
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Profit/hr
:done()
:tag('th')
Line 225 ⟶ 247:
:attr{ colspan = '10' }
:wikitext('Coins/XP')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Coins/XP with [[File:Merchant_small_icon.png|18px]] discount')
:done()
:done()
Line 261 ⟶ 287:
:IF(not(item.passiveActivity))
local
for i, _ in ipairs(item.
end
Line 285 ⟶ 311:
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(
:done()
:node(currency_cell(item.
:IF(item.XP)
Line 306 ⟶ 332:
:node(currency_cell(item.profitPerXP))
:node(currency_cell(item.profitPerXPDiscount))
:done()
|