Module:Skills/Gathering: Difference between revisions

Fixed Level/XP issues with Abyssal Constellations; Added additional requirements to Abyssal Stars;
(_buildAstrologyConstellationTable: Amend for revised constellation modifier data format)
(Fixed Level/XP issues with Abyssal Constellations; Added additional requirements to Abyssal Stars;)
(3 intermediate revisions by one other user 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 = Shared.round(lootValue[currID], 2, 2)
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 = Shared.round(log.sellsFor / (baseInt / 1000), 2, 2)
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(Shared.formatnum(baseXP))
: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(Shared.round(XPSec, 2, 2))
: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(Shared.fraction(itemDef.weight, totalWt))
: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(Shared.formatnum(baseXP))
: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(Shared.formatnum(baseXP))
: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(Shared.round(XPSec, 2, 2))
: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(Shared.fraction(1, Shared.round2(1/(odds/100), 0)))
: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(Shared.round(odds, 4, 4) .. '%')
: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, Shared.formatnum(loot.minQuantity) .. ' - ' .. Shared.formatnum(loot.maxQuantity))
table.insert(normalTxt, Num.formatnum(loot.minQuantity) .. ' - ' .. Num.formatnum(loot.maxQuantity))
else
else
table.insert(normalTxt, Shared.formatnum(loot.maxQuantity))
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, '|'..Shared.fraction(loot.weight * lootChance, totalWt * 100))
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"|'..Shared.round(dropChance, 2, 2)..'%')
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"|'..Shared.fraction(lootChance, 100)..'||')
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"|'..Shared.round(lootChance, 2, 2)..'%')
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..'"| '..Shared.formatnum(drop.quantity)..'||data-sort-value="'..thisItem.sellsFor..'"|'..Items.getValueText(thisItem)
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"|'..Shared.fraction(1, 1/(SkillData.Thieving.baseAreaUniqueChance/100))
lineTxt = lineTxt..'||style="text-align:right"|'..Num.fraction(1, 1/(SkillData.Thieving.baseAreaUniqueChance/100))
lineTxt = lineTxt..'||'..Shared.round(SkillData.Thieving.baseAreaUniqueChance, 2, 2)..'%'
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(Shared.formatnum(baseXP))
             :wikitext(Num.formatnum(baseXP))
         row:tag('td'):css('text-align', 'right')
         row:tag('td'):css('text-align', 'right')
             :wikitext(Shared.formatnum(npc.maxHit * 10))
             :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(Shared.formatnum(npc.perception))
             :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(Shared.formatnum(baseXP))
: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', 2):wikitext(modType.name .. ' Stars')
        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 = {}
local modText = {}
Line 1,263: Line 1,283:
                         cell1:wikitext(masteryLevel)
                         cell1:wikitext(masteryLevel)
                         :css('text-align', 'right')
                         :css('text-align', 'right')
                         cell2:wikitext(table.concat(modText, '<br>'))
                         cell3:wikitext(table.concat(modText, '<br>'))
                     else
                     else
                         cell1:attr('colspan', 2)
                         cell1:attr('colspan', 2)
Line 1,274: Line 1,294:
     end
     end


    return tostring(root)
return tostring(root)
end
end