Anonymous

Module:ModifierTables: Difference between revisions

From Melvor Idle
Add Mastery Pool Bonuses to Modifier Tables
(Remove deprecated skill parameter)
(Add Mastery Pool Bonuses to Modifier Tables)
 
(8 intermediate revisions by 3 users not shown)
Line 7: Line 7:
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Common = require('Module:Common')
local Common = require('Module:Common')
local Num = require('Module:Number')
local Icons = require('Module:Icons')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local Modifiers = require('Module:Modifiers')
local Modifiers = require('Module:Modifiers')
local SkillTree = require('Module:SkillTree')
local Items = require('Module:Items')
local Shop = require('Module:Shop')
local Pets = require('Module:Pets')
local Pets = require('Module:Pets')
local Items = require('Module:Items')
local Skills = require('Module:Skills')
local Skills = require('Module:Skills')
local Agility = require('Module:Skills/Agility')
local Agility = require('Module:Skills/Agility')
local Cartography = require('Module:Skills/Cartography')
local Prayer = require('Module:Prayer')
local Prayer = require('Module:Prayer')
local Shop = require('Module:Shop')
local Summoning = require('Module:Skills/Summoning')
local Icons = require('Module:Icons')
local Township = require('Module:Township')
local Cartography = require('Module:Skills/Cartography')
 
local GameData = require('Module:GameData')
local Num = require('Module:Number')


--First up, functions to get all the things in a category that have a given modifier:
--First up, functions to get all the things in a category that have a given modifier:
Line 32: Line 37:
end)
end)
return itemList
return itemList
end
function p.getSkillTreeNodesWithModifier(modifierCriteria)
    local nodesWithModifier = SkillTree.getSkillTreeNodes(
        function(node)
            if node.modifiers ~= nil then
                local mods = Modifiers.getMatchingModifiers(node.modifiers, modifierCriteria)
                if not Shared.tableIsEmpty(mods.matched) then
                    return true
                end
            end
            return false
        end
    )
    return nodesWithModifier
end
end


Line 154: Line 174:
end
end


function p._getModifierTable(modifiers, globalProps, columnName, getOpposites, displayOtherMods, maxOtherMods, forceMagnitudeSort)
function p.getAncientRelicsWithModifiers(modifierCriteria)
local matchedRelics = {}
 
for i, relic in ipairs(GameData.rawData.ancientRelics) do
if relic.modifiers ~= nil then
local mods = Modifiers.getMatchingModifiers(relic.modifiers, modifierCriteria)
if not Shared.tableIsEmpty(mods.matched) then
table.insert(matchedRelics, relic)
end
end
end
 
return matchedRelics
end
 
function p.getBuildingsWithModifiers(modifierCriteria)
local buildingList = Township.getBuildings(
function(building)
if building.modifiers == nil or Shared.tableIsEmpty(building.modifiers) then
return false
end
local mods = Modifiers.getMatchingModifiers(building.modifiers, modifierCriteria)
return not Shared.tableIsEmpty(mods.matched)
end)
 
return buildingList
end
 
function p.getSeasonsWithModifiers(modifierCriteria)
local seasonList = Township.getSeasons(
function(season)
if season.modifiers == nil or Shared.tableIsEmpty(season.modifiers) then
return false
end
local mods = Modifiers.getMatchingModifiers(season.modifiers, modifierCriteria)
return not Shared.tableIsEmpty(mods.matched)
end)
 
return seasonList
end
 
function p.getSummoningSynergiesWithModifiers(modifierCriteria)
local synergyList = Summoning.getSynergies(
function(synergy)
if synergy.modifiers == nil or Shared.tableIsEmpty(synergy.modifiers) then
return false
end
local mods = Modifiers.getMatchingModifiers(synergy.modifiers, modifierCriteria)
return not Shared.tableIsEmpty(mods.matched)
end)
 
return synergyList
end
 
function p.getMasteryPoolModifiers(modifierCriteria)
local masteryPoolList = {}
for skillName, skillData in pairs(SkillData) do
if skillData.masteryPoolBonuses ~= nil then
for i, masteryPool in ipairs(skillData.masteryPoolBonuses) do
local mods = Modifiers.getMatchingModifiers(masteryPool.modifiers, modifierCriteria)
if not Shared.tableIsEmpty(mods.matched) then
table.insert(masteryPoolList, { [skillName] = masteryPool })
end
end
end
end
 
return masteryPoolList
end
 
function p._getModifierTable(modifiers, globalProps, columnName, getOpposites, displayOtherMods, maxOtherMods, forceMagnitudeSort, collapsed)
local modifierIDs = {}
local modifierIDs = {}
if type(modifiers) == 'string' then
if type(modifiers) == 'string' then
Line 275: Line 366:
table.insert(tableArray, row)
table.insert(tableArray, row)
end
end
local nodeList = p.getSkillTreeNodesWithModifier(modifierCriteria)
for _, node in ipairs(nodeList) do
    local row = {}
    row.name = node.skillName .. " - " .. node.name
   
    local firstIcon = Icons.Icon({"", img='Skill Tree', nolink=true})
    local secondIcon = Icons.Icon({node.skillName..'%23#Skill_Tree', node.name, type='skill', img=node.skillName})
    row.icon = firstIcon .. " " .. secondIcon
   
    row.expIcon = Icons.getDLCColumnIcon(node.id)
    row.expSort = Icons.getExpansionID(node.id)
    row.type = '[[Skill Tree#Nodes|Skill Tree Node]]'
    row.typeText = 'Skill Tree Node'
    local objMods = nil
    row.modifierText, row.otherModifiers, objMods = getModText(node.modifiers)
    row.val = Modifiers.getModifierValue(objMods.matched)
    if not hasOtherModifiers and not Shared.tableIsEmpty(objMods.unmatched) then
        hasOtherModifiers = true
    end
    table.insert(tableArray, row)
end


local obstList = p.getObstaclesWithModifier(modifierCriteria)
local obstList = p.getObstaclesWithModifier(modifierCriteria)
Line 441: Line 558:
table.insert(tableArray, row)
table.insert(tableArray, row)
end
local ancientRelicList = p.getAncientRelicsWithModifiers(modifierCriteria)
for i, relic in ipairs(ancientRelicList) do
local row = {}
local relicName = relic.name
local sectionName = 'Melvor Realm'
if string.find(relic.id, 'Abyssal') ~= nil then
relicName = 'Abyssal ' .. relicName
sectionName = 'Abyssal Realm'
end
row.name = relicName
row.icon = Icons.Icon({'Ancient Relics', relicName, section=sectionName})
row.expIcon = Icons.getDLCColumnIcon(relic.id)
row.expSort = Icons.getExpansionID(relic.id)
row.type = Icons.Icon({'Ancient Relics', 'Ancient Relic', noicon=true})
row.typeText = 'Ancient Relic'
local objMods = nil
row.modifierText, row.otherModifiers, objMods = getModText(relic.modifiers)
row.val = Modifiers.getModifierValue(objMods.matched)
if not hasOtherModifiers and not Shared.tableIsEmpty(objMods.unmatched) then
hasOtherModifiers = true
end
table.insert(tableArray, row)
end
local buildingList = p.getBuildingsWithModifiers(modifierCriteria)
for i, building in ipairs(buildingList) do
local row = {}
row.name = building.name
row.icon = Icons.Icon({building.name, type='building'})
row.expIcon = Icons.getDLCColumnIcon(building.id)
row.expSort = Icons.getExpansionID(building.id)
row.type = Icons.Icon({'Township', 'Building', section='Buildings', type='skill', noicon=true})
row.typeText = 'Building'
local modList = {}
-- Multiply mod value by max upgrades to get the total modifier value
for modID, value in pairs(building.modifiers) do
if type(value) == 'table' then
modList[modID] = value[1].value * building.maxUpgrades
else
modList[modID] = value * building.maxUpgrades
end
end
local objMods = nil
row.modifierText, row.otherModifiers, objMods = getModText(modList)
row.val = Modifiers.getModifierValue(objMods.matched)
if not hasOtherModifiers and not Shared.tableIsEmpty(objMods.unmatched) then
hasOtherModifiers = true
end
table.insert(tableArray, row)
end
local seasonList = p.getSeasonsWithModifiers(modifierCriteria)
for i, season in ipairs(seasonList) do
local row = {}
row.name = season.name
row.icon = Icons.Icon({season.name, type='township'})
row.expIcon = Icons.getDLCColumnIcon(season.id)
row.expSort = Icons.getExpansionID(season.id)
row.type = Icons.Icon({'Township', 'Season', section='Seasons', type='skill', noicon=true})
row.typeText = 'Season'
local objMods = nil
row.modifierText, row.otherModifiers, objMods = getModText(season.modifiers)
row.val = Modifiers.getModifierValue(objMods.matched)
if not hasOtherModifiers and not Shared.tableIsEmpty(objMods.unmatched) then
hasOtherModifiers = true
end
table.insert(tableArray, row)
end
local summoningSynergyList = p.getSummoningSynergiesWithModifiers(modifierCriteria)
for i, synergy in ipairs(summoningSynergyList) do
local row = {}
local famProduct1 = Summoning.getFamiliarRecipeByID(synergy.summonIDs[1])
local familiar1 = nil
local famProduct2 = Summoning.getFamiliarRecipeByID(synergy.summonIDs[2])
local familiar2 = nil
if famProduct1 ~= nil then
familiar1 = Items.getItemByID(famProduct1.productID)
end
if famProduct2 ~= nil then
familiar2 = Items.getItemByID(famProduct2.productID)
end
if familiar1 == nil or familiar2 == nil then
return
end
row.name = familiar1.name .. familiar2.name .. ' Synergy'
row.icon = Icons.Icon({familiar1.name, type='item'}) .. ' ' .. Icons.Icon({'SynergyIcon', notext=true, nolink=true}) .. ' ' .. Icons.Icon({familiar2.name, type='item'}) .. ' Synergy'
row.expIcon = Icons.getDLCColumnIcon(familiar2.id)
row.expSort = Icons.getExpansionID(familiar2.id)
row.type = Icons.Icon({'Summoning', 'Summoning Synergy', section='Synergies', type='skill', noicon=true})
row.typeText = 'Synergy'
local objMods = nil
row.modifierText, row.otherModifiers, objMods = getModText(synergy.modifiers)
row.val = Modifiers.getModifierValue(objMods.matched)
if not hasOtherModifiers and not Shared.tableIsEmpty(objMods.unmatched) then
hasOtherModifiers = true
end
table.insert(tableArray, row)
end
local masteryPools = p.getMasteryPoolModifiers(modifierCriteria)
for i, masteryPoolData in ipairs(masteryPools) do
for skillName, masteryPool in pairs(masteryPoolData) do
local row = {}
local isAbyssal = masteryPool.realm == 'melvorItA:Abyssal' and 'Abyssal ' or ''
row.name = isAbyssal .. masteryPool.percent .. '% Mastery Pool Bonus'
row.icon = Icons.Icon({skillName, row.name, section='Mastery Pool Checkpoints', type='skill'})
row.expIcon = Icons.getDLCColumnIcon(masteryPool.realm)
row.expSort = Icons.getExpansionID(masteryPool.realm)
row.type = Icons.Icon({skillName, 'Mastery Pool Bonus', section='Mastery Pool Checkpoints', type='skill', noicon=true})
row.typeText = 'Mastery Pool Bonus'
local objMods = nil
row.modifierText, row.otherModifiers, objMods = getModText(masteryPool.modifiers)
row.val = Modifiers.getModifierValue(objMods.matched)
if not hasOtherModifiers and not Shared.tableIsEmpty(objMods.unmatched) then
hasOtherModifiers = true
end
table.insert(tableArray, row)
end
end
end


local html = mw.html.create('table')
local html = mw.html.create('table')
:addClass("wikitable sortable stickyHeader mw-collapsible")
:addClass("wikitable sortable stickyHeader mw-collapsible")
if collapsed == true then
html:addClass("mw-collapsed")
end
local header = html:tag('tr'):addClass("headerRow-0")
local header = html:tag('tr'):addClass("headerRow-0")
Line 496: Line 756:
local forceMagnitudeSort = string.upper(tostring(args.forceMagnitudeSort)) == 'TRUE' or false
local forceMagnitudeSort = string.upper(tostring(args.forceMagnitudeSort)) == 'TRUE' or false
local globalPropsText = args.filters
local globalPropsText = args.filters
local collapsed = string.upper(tostring(args.collapsed)) == 'TRUE' or false


if getOpposites ~= nil then
if getOpposites ~= nil then
Line 551: Line 812:
end
end


 
return p._getModifierTable(modifierList, globalProps, columnName, getOpposites, displayOtherMods, maxOtherMods, forceMagnitudeSort, collapsed)
return p._getModifierTable(modifierList, globalProps, columnName, getOpposites, displayOtherMods, maxOtherMods, forceMagnitudeSort)
end
end


Line 567: Line 827:
-- First, sort modifiers
-- First, sort modifiers
local modifierNames = {}
local modifierNames = {}
for k, _ in pairs(GameData.rawData.modifierData) do
for k, _ in pairs(Modifiers.ModifierIndex.localID) do
table.insert(modifierNames, tostring(k))
table.insert(modifierNames, k)
end
end
table.sort(modifierNames)
table.sort(modifierNames)