Module:DetectivePassiveList: Difference between revisions
offload much of the search, screen, and format functions to the new ProfessionList module, so they work the same for all table
m (detective icon) |
(offload much of the search, screen, and format functions to the new ProfessionList module, so they work the same for all table) |
||
Line 1:
require('strict')
require('Module:Mw.html extension')
local lang = mw.getContentLanguage()
local
local rts = require('Module:RecipeTreeSearch')
local p = {}
Line 10:
function p.main()
local queryString = '[[Category:Detective]] AND [[Category:Pages with activities]]'
local
return item.passive
end
local results = plist.generate_recipe_table(queryString,screenFunction)
results = p.formatResults(results)
Line 35 ⟶ 25:
--return '<pre>'..mw.text.jsonEncode(results, mw.text.JSON_PRETTY)..'</pre>'
end
-- do calculations and determine strings to go in cells
function p.formatResults(results)
--simple check for nil results
if results==nil or results[1]==nil then
return nil
end
-- iterate through products
for _, item in ipairs(results) do
item.
-- work out if the product is coins or items
item.usesPotion = string.find(item.
if not item.usesPotion then
item.profit = item.coins
else
item.potion = (item.materials and item.materials[1] and item.materials[1].name) or ''
item.profit = item.coins and item.buyPrice and item.coins - item.buyPrice
end
-- no downtime for passives
item.productPerHour = item.duration and 1 / item.duration * 3600
-- properties per hour
item.
item.profitPerHour = item.
end
Line 92 ⟶ 62:
-- make the table
function p.displayTable(results)
--simple check for nil results
if results==nil or results[1]==nil then
return 'No data found for table'
end
local out = mw.html.create('table')
:addClass('wikitable sortable')
Line 103 ⟶ 79:
:done()
:tag('th')
:attr{ colspan = '3' }
:wikitext('Materials')
:done()
Line 112 ⟶ 89:
:attr{ colspan = '10' }
:wikitext('Payment')
:done()
:tag('th')
Line 128 ⟶ 101:
:done()
:done()
for i, item in ipairs(results) do
Line 138 ⟶ 106:
--level
:IF(item.
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(item.
:done()
:ELSE()
:node(plist.unknown_value_edit_cell(item.pageName,1))
:END()
-- activity
:node(plist.two_column_image_text(item.pageName,item.pageImage,item.pageName,item.pageName))
-- materials
:IF(item.usesPotion)
:node(plist.three_column_image_text(item.potion,item.output[1].quantity,'File:'..item.potion..'.png',item.potion,item.potion))
:node(plist.currency_cell(item.buyPrice))
:ELSE()
:tag('td')
:addClass('table-na')
:attr{ colspan = '
:wikitext('N/A')
:done()
:END()
-- payment
:
:node(plist.currency_cell(item.coins))
:ELSE()
:node(plist.unknown_value_edit_cell(item.pageName,10))
:END()
--
:node(plist.currency_cell(item.profitPerHour))
-- XP
:IF(item.
:tag('td')
:wikitext(item.
:done()
:ELSE()
:node(plist.unknown_value_edit_cell(item.pageName,1))
:END()
-- XP per hour
:IF(item.
:tag('td')
:wikitext(item.
:done()
:ELSE()
:node(plist.unknown_value_cell(1))
:END()
|