20
edits
(Created page with "local p = {} local Constants = require('Module:Constants') local Shared = require('Module:Shared') local GameData = require('Module:GameData') local SkillData = GameData.skillData local Magic = require('Module:Magic') local Icons = require('Module:Icons') local Items = require('Module:Items') local Shop = require('Module:Shop') local Monsters = require('Module:Monsters') local Skills = require('Module:Skills') function p._getCreationTable(item) local skill = '' loca...") |
(getItemFarmTable first pass) |
||
Line 1,097: | Line 1,097: | ||
local item = Items.getItem(itemName) | local item = Items.getItem(itemName) | ||
return p._getItemMonsterSources(item) | return p._getItemMonsterSources(item) | ||
end | |||
function p.getItemFarmTable(frame) | |||
local itemName = frame.args ~= nil and frame.args[1] or frame[1] | |||
local quantity = frame.args ~= nil and frame.args[2] or frame[2] | |||
local item = Items.getItem(itemName) | |||
if item == nil then | |||
return Shared.printError('No item named "' .. itemName .. '" exists in the data module') | |||
end | |||
return p._getItemFarmTable(itemName, quantity) | |||
end | |||
function p._getItemFarmTable(itemName, quantity) | |||
local monsterResults = {} | |||
local output = {} | |||
table.insert(output, '{| class="wikitable" style="width: 100%;"') | |||
table.insert(output, '{| class="wikitable sortable" style="width: 100%;"') | |||
table.insert(output, '! style="width: 25%;"|{{ItemIcon|'..itemName..'|notext=true|size=50}} x'..quantity) | |||
table.insert(output, '! colspan="3"|[['..itemName..']]') | |||
table.insert(output, '!') | |||
table.insert(output, '|-') | |||
table.insert(output, '! Monster') | |||
table.insert(output, '! {{Skill|Hitpoints|notext=true}} Effective HP<br> (including DR)') | |||
table.insert(output, '! Drop Chance') | |||
table.insert(output, '! Avg. Kills') | |||
table.insert(output, '! Avg. Damage Required') | |||
for i, v in ipairs(p.getItemMonsterSources(itemName)) do | |||
local monster = Monsters.getMonsterByID(v.id) | |||
local effectiveHp = Monsters.getMonsterEffectiveHP(monster.name) | |||
local dropChance = Monsters.getItemDropChance({monster.name, itemName}) | |||
table.insert(monsterResults, {monster = monster, effectiveHp = effectiveHp, dropChance = dropChance}) | |||
end | |||
for i, v in ipairs(monsterResults) do | |||
table.insert(output, '|-') | |||
table.insert(output, '| {{MonsterIcon|'..v.monster.name..'}}') | |||
table.insert(output, '| {{#invoke:Shared|formatNumber|'..v.effectiveHp..'}}') | |||
table.insert(output, '| '..v.dropChance..'%') | |||
table.insert(output, '| {{#invoke:Shared|formatNumber|{{#expr:'..(quantity/(v.dropChance/100))..' round 0}}}}') | |||
table.insert(output, '| {{#invoke:Shared|formatNumber|{{#expr:('..(quantity/(v.dropChance/100))..' round 0) *'..v.effectiveHp..'}}}}') | |||
end | |||
table.insert(output, '|-') | |||
table.insert(output, '|}') | |||
return table.concat(output, '\r\n') | |||
end | end | ||
edits