Anonymous

Module:Skills/Gathering: Difference between revisions

From Melvor Idle
_buildAstrologyModifierArray: Add option to return standard modifier key/value pairs
(_buildAstrologyModifierArray: Initial implementation; _buildAstrologyConstellationTable: Use _buildAstrologyModifierArray)
(_buildAstrologyModifierArray: Add option to return standard modifier key/value pairs)
Line 718: Line 718:
-- includeUnique: true|false, determines whether unique modifiers are included
-- includeUnique: true|false, determines whether unique modifiers are included
-- isDistinct: true|false, if true, the returned list of modifiers is de-duplicated
-- isDistinct: true|false, if true, the returned list of modifiers is de-duplicated
function p._buildAstrologyModifierArray(cons, modValue, includeStandard, includeUnique, isDistinct)
-- asKeyValue: true|false, if true, returns key/value pairs like usual modifier objects
function p._buildAstrologyModifierArray(cons, modValue, includeStandard, includeUnique, isDistinct, asKeyValue)
-- Temporary function to determine if the table already contains a given modifier
-- Temporary function to determine if the table already contains a given modifier
local containsMod = function(modList, modNew)
local containsMod = function(modList, modNew)
Line 734: Line 735:
end
end
return false
return false
end
local addToArray = function(modArray, modNew)
if not isDistinct or (isDistinct and not containsMod(modArray, modNew)) then
if asKeyValue then
if modArray[modNew[1]] == nil then
modArray[modNew[1]] = { modNew[2] }
else
table.insert(modArray[modNew[1]], modNew[2])
end
else
table.insert(modArray, modNew)
end
end
end
end
Line 746: Line 761:
-- Check if modifier varies by skill, and amend the modifier value accordingly
-- Check if modifier varies by skill, and amend the modifier value accordingly
local modVal = (Shared.contains(modText, '{SV0}') and {skillID, modValue}) or modValue
local modVal = (Shared.contains(modText, '{SV0}') and {skillID, modValue}) or modValue
local newMod = {modName, modVal}
addToArray(modArray, {modName, modVal})
if not isDistinct or (isDistinct and not containsMod(modArray, newMod)) then
table.insert(modArray, newMod)
end
end
end
end
end
Line 770: Line 782:
for j, skillID in ipairs(cons.skills) do
for j, skillID in ipairs(cons.skills) do
if not modBase.isSkill or (modBase.isSkill and skillArray[j].hasMastery) then
if not modBase.isSkill or (modBase.isSkill and skillArray[j].hasMastery) then
local newMod = {modName, {skillID, modValue}}
addToArray(modArray, {modName, {skillID, modValue}})
if not isDistinct or (isDistinct and not containsMod(modArray, newMod)) then
table.insert(modArray, newMod)
end
end
end
end
end
elseif not isDistinct or (isDistinct and not containsMod(modArray, {modName, modValue})) then
else
table.insert(modArray, {modName, modValue})
addToArray(modArray, {modName, modValue})
end
end
end
end
Line 804: Line 813:
result = result..'||'..table.concat(skillIconArray, '<br/>')
result = result..'||'..table.concat(skillIconArray, '<br/>')
local standModsRaw = p._buildAstrologyModifierArray(cons, maxModifier, true, false, false)
local standModsRaw = p._buildAstrologyModifierArray(cons, maxModifier, true, false, false, false)
local standMods = {}
local standMods = {}
--Building the list of Standard modifiers:
--Building the list of Standard modifiers:
Line 813: Line 822:
--Building the list of all Unique Modifiers
--Building the list of all Unique Modifiers
local uModsRaw = p._buildAstrologyModifierArray(cons, maxModifier, false, true, false)
local uModsRaw = p._buildAstrologyModifierArray(cons, maxModifier, false, true, false, false)
local uMods = {}
local uMods = {}
for j, modifier in ipairs(uModsRaw) do
for j, modifier in ipairs(uModsRaw) do