3,987
edits
(getFarmingFoodTable: Better support for realms) |
(Fixed Level/XP issues with Abyssal Constellations; Added additional requirements to Abyssal Stars;) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 12: | Line 12: | ||
local Skills = require('Module:Skills') | local Skills = require('Module:Skills') | ||
local ItemSourceTables = require('Module:Items/SourceTables') | local ItemSourceTables = require('Module:Items/SourceTables') | ||
local Num = require("Module:Number") | |||
local function lootValueText(lootValue) | local function lootValueText(lootValue) | ||
Line 18: | Line 19: | ||
-- Guarantee order by iterating through currency game data definition | -- Guarantee order by iterating through currency game data definition | ||
local currID = currencyDefn.id | local currID = currencyDefn.id | ||
local val = | local val = Num.round(lootValue[currID], 2, 2) | ||
if val ~= nil then | if val ~= nil then | ||
table.insert(returnPart, Icons._Currency(currID, val)) | table.insert(returnPart, Icons._Currency(currID, val)) | ||
Line 66: | Line 67: | ||
local sellCurrency = log.sellsForCurrency or 'melvorD:GP' | local sellCurrency = log.sellsForCurrency or 'melvorD:GP' | ||
local XPSec = baseXP / (baseInt / 1000) | local XPSec = baseXP / (baseInt / 1000) | ||
local currSec = | local currSec = Num.round(log.sellsFor / (baseInt / 1000), 2, 2) | ||
Line 83: | Line 84: | ||
:attr('data-sort-value', Icons.getExpansionID(tree.id)) | :attr('data-sort-value', Icons.getExpansionID(tree.id)) | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:tag('td'):wikitext( | :tag('td'):wikitext(Num.formatnum(baseXP)) | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:tag('td'):wikitext(Shared.timeString(baseInt / 1000, true)) | :tag('td'):wikitext(Shared.timeString(baseInt / 1000, true)) | ||
:attr('data-sort-value', baseInt) | :attr('data-sort-value', baseInt) | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:tag('td'):wikitext( | :tag('td'):wikitext(Num.round(XPSec, 2, 2)) | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:tag('td'):wikitext(Icons._Currency(sellCurrency, currSec)) | :tag('td'):wikitext(Icons._Currency(sellCurrency, currSec)) | ||
Line 145: | Line 146: | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:attr('data-sort-value', itemDef.weight) | :attr('data-sort-value', itemDef.weight) | ||
:wikitext( | :wikitext(Num.fraction(itemDef.weight, totalWt)) | ||
row:tag('td') | row:tag('td') | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
Line 257: | Line 258: | ||
:attr('data-sort-value', Icons.getExpansionID(oreData.id)) | :attr('data-sort-value', Icons.getExpansionID(oreData.id)) | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:tag('td'):wikitext( | :tag('td'):wikitext(Num.formatnum(baseXP)) | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
local respawn = | local respawn = | ||
Line 421: | Line 422: | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:attr('data-sort-value', baseXP) | :attr('data-sort-value', baseXP) | ||
:wikitext( | :wikitext(Num.formatnum(baseXP)) | ||
row:tag('td') | row:tag('td') | ||
:attr('data-sort-value', fish.sellsFor) | :attr('data-sort-value', fish.sellsFor) | ||
Line 427: | Line 428: | ||
row:tag('td') | row:tag('td') | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:wikitext( | :wikitext(Num.round(XPSec, 2, 2)) | ||
end | end | ||
end | end | ||
Line 543: | Line 544: | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:attr('data-sort-value', odds) | :attr('data-sort-value', odds) | ||
:wikitext( | :wikitext(Num.fraction(1, Num.round2(1/(odds/100), 0))) | ||
row:tag('td') | row:tag('td') | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:attr('data-sort-value', odds) | :attr('data-sort-value', odds) | ||
:wikitext( | :wikitext(Num.round(odds, 4, 4) .. '%') | ||
end | end | ||
end | end | ||
Line 602: | Line 603: | ||
if loot.minQuantity ~= loot.maxQuantity then | if loot.minQuantity ~= loot.maxQuantity then | ||
table.insert(normalTxt, | table.insert(normalTxt, Num.formatnum(loot.minQuantity) .. ' - ' .. Num.formatnum(loot.maxQuantity)) | ||
else | else | ||
table.insert(normalTxt, | table.insert(normalTxt, Num.formatnum(loot.maxQuantity)) | ||
end | end | ||
Line 622: | Line 623: | ||
--Show fraction as long as it isn't going to be 1/1 | --Show fraction as long as it isn't going to be 1/1 | ||
table.insert(normalTxt, '||style="text-align:right" data-sort-value="'..loot.weight..'"') | table.insert(normalTxt, '||style="text-align:right" data-sort-value="'..loot.weight..'"') | ||
table.insert(normalTxt, '|'.. | table.insert(normalTxt, '|'..Num.fraction(loot.weight * lootChance, totalWt * 100)) | ||
table.insert(normalTxt, '||') | table.insert(normalTxt, '||') | ||
else | else | ||
table.insert(normalTxt, '||colspan="2" data-sort-value="'..loot.weight..'"') | table.insert(normalTxt, '||colspan="2" data-sort-value="'..loot.weight..'"') | ||
end | end | ||
table.insert(normalTxt, 'style="text-align:right"|'.. | table.insert(normalTxt, 'style="text-align:right"|'..Num.round(dropChance, 2, 2)..'%') | ||
--Adding to the average loot value based on price & dropchance | --Adding to the average loot value based on price & dropchance | ||
Line 640: | Line 641: | ||
table.insert(normalTxt, '\r\n|-class="sortbottom" \r\n!colspan="3"|Total:') | table.insert(normalTxt, '\r\n|-class="sortbottom" \r\n!colspan="3"|Total:') | ||
if lootChance < 100 then | if lootChance < 100 then | ||
table.insert(normalTxt, '\r\n|style="text-align:right"|'.. | table.insert(normalTxt, '\r\n|style="text-align:right"|'..Num.fraction(lootChance, 100)..'||') | ||
else | else | ||
table.insert(normalTxt, '\r\n|colspan="2" ') | table.insert(normalTxt, '\r\n|colspan="2" ') | ||
end | end | ||
table.insert(normalTxt, 'style="text-align:right"|'.. | table.insert(normalTxt, 'style="text-align:right"|'..Num.round(lootChance, 2, 2)..'%') | ||
end | end | ||
table.insert(normalTxt, '\r\n|}') | table.insert(normalTxt, '\r\n|}') | ||
Line 678: | Line 679: | ||
local lineTxt = '' | local lineTxt = '' | ||
lineTxt = lineTxt..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | lineTxt = lineTxt..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | ||
lineTxt = lineTxt..'||data-sort-value="'..drop.quantity..'"| '.. | lineTxt = lineTxt..'||data-sort-value="'..drop.quantity..'"| '..Num.formatnum(drop.quantity)..'||data-sort-value="'..thisItem.sellsFor..'"|'..Items.getValueText(thisItem) | ||
lineTxt = lineTxt..'||style="text-align:right"|'.. | lineTxt = lineTxt..'||style="text-align:right"|'..Num.fraction(1, 1/(SkillData.Thieving.baseAreaUniqueChance/100)) | ||
lineTxt = lineTxt..'||'.. | lineTxt = lineTxt..'||'..Num.round(SkillData.Thieving.baseAreaUniqueChance, 2, 2)..'%' | ||
dropLines[thisItem.name] = lineTxt | dropLines[thisItem.name] = lineTxt | ||
end | end | ||
Line 768: | Line 769: | ||
:attr('data-sort-value', Icons.getExpansionID(npc.id)) | :attr('data-sort-value', Icons.getExpansionID(npc.id)) | ||
row:tag('td'):css('text-align', 'right') | row:tag('td'):css('text-align', 'right') | ||
:wikitext( | :wikitext(Num.formatnum(baseXP)) | ||
row:tag('td'):css('text-align', 'right') | row:tag('td'):css('text-align', 'right') | ||
:wikitext( | :wikitext(Num.formatnum(npc.maxHit * 10)) | ||
row:tag('td'):css('text-align', 'right') | row:tag('td'):css('text-align', 'right') | ||
:attr('data-sort-value', npc.perception) | :attr('data-sort-value', npc.perception) | ||
:wikitext( | :wikitext(Num.formatnum(npc.perception)) | ||
row:tag('td'):attr('data-sort-value', currSortAmt) | row:tag('td'):attr('data-sort-value', currSortAmt) | ||
:wikitext(p._getThievingNPCCurrencyText(npc)) | :wikitext(p._getThievingNPCCurrencyText(npc)) | ||
Line 921: | Line 922: | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:attr('data-sort-value', Icons.getExpansionID(seedItem.id)) | :attr('data-sort-value', Icons.getExpansionID(seedItem.id)) | ||
:tag('td'):wikitext( | :tag('td'):wikitext(Num.formatnum(baseXP)) | ||
:tag('td'):attr('data-sort-value', (baseInt / 1000)) | :tag('td'):attr('data-sort-value', (baseInt / 1000)) | ||
:wikitext(Shared.timeString(baseInt / 1000, true)) | :wikitext(Shared.timeString(baseInt / 1000, true)) | ||
Line 1,198: | Line 1,199: | ||
for _, modType in ipairs(modTypes) do | for _, modType in ipairs(modTypes) do | ||
if modType.inUse then | if modType.inUse then | ||
headerRow1:tag('th'):attr('colspan', | local spanCount = modType.name == 'Abyssal' and 3 or 2 | ||
headerRow1:tag('th'):attr('colspan', spanCount):wikitext(modType.name .. ' Stars') | |||
headerRow2:tag('th'):wikitext(Icons.Icon({'Mastery', notext=true}) .. '<br>Level') | headerRow2:tag('th'):wikitext(Icons.Icon({'Mastery', notext=true}) .. '<br>Level') | ||
if modType.name == "Abyssal" then | |||
headerRow2:tag('th'):wikitext('Level') | |||
end | |||
headerRow2:tag('th'):wikitext('Modifiers') | headerRow2:tag('th'):wikitext('Modifiers') | ||
end | end | ||
Line 1,229: | Line 1,234: | ||
:wikitext(name) | :wikitext(name) | ||
row:tag('td'):attr('rowspan', maxRows) | row:tag('td'):attr('rowspan', maxRows) | ||
:wikitext(cons.level) | :wikitext((cons.abyssalLevel or cons.level)) | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
row:tag('td'):css('text-align', 'center') | row:tag('td'):css('text-align', 'center') | ||
Line 1,236: | Line 1,241: | ||
:wikitext(Icons.getDLCColumnIcon(cons.id)) | :wikitext(Icons.getDLCColumnIcon(cons.id)) | ||
row:tag('td'):attr('rowspan', maxRows) | row:tag('td'):attr('rowspan', maxRows) | ||
:wikitext(cons.baseExperience) | :wikitext(Num.formatnum(cons.baseAbyssalExperience or cons.baseExperience)) | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
row:tag('td'):attr('rowspan', maxRows) | row:tag('td'):attr('rowspan', maxRows) | ||
Line 1,248: | Line 1,253: | ||
local masteryLevel = modType.levels[rowIdx] | local masteryLevel = modType.levels[rowIdx] | ||
local rowModData = modData[modType.modKey][rowIdx] | local rowModData = modData[modType.modKey][rowIdx] | ||
local rowConsData = cons[modType.modKey][rowIdx] | |||
local cell1 = row:tag('td') | local cell1 = row:tag('td') | ||
local cell2 = row:tag('td') | if modType.name == "Abyssal" then | ||
local starUnlockReq = nil | |||
local cell2 = row:tag('td') | |||
if rowConsData ~= nil and rowConsData.unlockRequirements ~= nil and Shared.tableCount(rowConsData.unlockRequirements) == 2 then | |||
starUnlockReq = Common.getRequirementString({cons[modType.modKey][rowIdx].unlockRequirements[2]}, nil) | |||
end | |||
if starUnlockReq ~= nil then | |||
cell2:wikitext(starUnlockReq) | |||
:css('text-align', 'right') | |||
else | |||
cell2:wikitext('N/A') | |||
:addClass('table-na') | |||
end | |||
end | |||
local cell3 = row:tag('td') | |||
if masteryLevel ~= nil and rowModData ~= nil then | if masteryLevel ~= nil and rowModData ~= nil then | ||
local modText = {} | |||
for _, modKey in ipairs({'modifiers', 'enemyModifiers'}) do | |||
local mods = rowModData[modKey] | |||
if mods ~= nil then | |||
if modKey == 'enemyModifiers' then | |||
table.insert(modText, 'Gives the enemy:') | |||
end | |||
table.insert(modText, Modifiers.getModifiersText(mods, false, false, 10)) | |||
end | |||
end | |||
cell1:wikitext(masteryLevel) | cell1:wikitext(masteryLevel) | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
cell3:wikitext(table.concat(modText, '<br>')) | |||
else | else | ||
cell1:attr('colspan', 2) | cell1:attr('colspan', 2) | ||
Line 1,264: | Line 1,294: | ||
end | end | ||
return tostring(root) | |||
end | end | ||