Anonymous

Module:Skills/Gathering: Difference between revisions

From Melvor Idle
_buildAstrologyModifierArray: Initial implementation; _buildAstrologyConstellationTable: Use _buildAstrologyModifierArray
(_buildAstrologyConstellationTable: Temporarily fix issue that I created by altering the behaviour of Constants._getModifierText)
(_buildAstrologyModifierArray: Initial implementation; _buildAstrologyConstellationTable: Use _buildAstrologyModifierArray)
Line 711: Line 711:
return resultArray
return resultArray
end
-- For a given constellation cons and modifier value modValue, generates and returns
-- a table of modifiers, much like any other item/object elsewhere in the game.
-- includeStandard: true|false, determines whether standard 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
function p._buildAstrologyModifierArray(cons, modValue, includeStandard, includeUnique, isDistinct)
-- Temporary function to determine if the table already contains a given modifier
local containsMod = function(modList, modNew)
for i, modItem in ipairs(modList) do
-- Check mod names & value data types both equal
if modItem[1] == modNew[1] and type(modItem[2]) == type(modNew[2]) then
if type(modItem[2]) == 'table' then
if Shared.tablesEqual(modItem[2], modNew[2]) then
return true
end
elseif modItem[2] == modNew[2] then
return true
end
end
end
return false
end
local modArray = {}
-- Standard modifiers
if includeStandard then
for i, skillMods in ipairs(cons.standardModifiers) do
local skillID = cons.skills[i]
if skillID ~= nil then
for j, modName in ipairs(skillMods) do
local modBaseName, modText, sign, isNegative, unsign, modBase = Constants.getModifierDetails(modName)
-- Check if modifier varies by skill, and amend the modifier value accordingly
local modVal = (Shared.contains(modText, '{SV0}') and {skillID, modValue}) or modValue
local newMod = {modName, modVal}
if not isDistinct or (isDistinct and not containsMod(modArray, newMod)) then
table.insert(modArray, newMod)
end
end
end
end
end
-- Unique modifiers
if includeUnique then
local skillArray = {}
for i, skillID in ipairs(cons.skills) do
table.insert(skillArray, SkillData.Skills[skillID + 1])
end
for i, modName in ipairs(cons.uniqueModifiers) do
-- The most important thing we're getting here is the modText and modBase
-- modText lets us check if this is a per-skill modifier or not
-- modBase lets us check .isSkill, which are modifiers that we only use for skills with Mastery
local modBaseName, modText, sign, isNegative, unsign, modBase = Constants.getModifierDetails(modName)
if Shared.contains(modText, '{SV0}') then
-- Check which skills the current modifier can be used for
for j, skillID in ipairs(cons.skills) do
if not modBase.isSkill or (modBase.isSkill and skillArray[j].hasMastery) then
local newMod = {modName, {skillID, modValue}}
if not isDistinct or (isDistinct and not containsMod(modArray, newMod)) then
table.insert(modArray, newMod)
end
end
end
elseif not isDistinct or (isDistinct and not containsMod(modArray, {modName, modValue})) then
table.insert(modArray, {modName, modValue})
end
end
end
return modArray
end
end


Line 725: Line 797:
result = result..'\r\n|data-sort-value="'..name..'"|'..Icons.Icon({name, type='constellation', size='50', notext=true})..'||'..name
result = result..'\r\n|data-sort-value="'..name..'"|'..Icons.Icon({name, type='constellation', size='50', notext=true})..'||'..name
result = result..'||'..cons.level..'||'..cons.provides.xp
result = result..'||'..cons.level..'||'..cons.provides.xp
local standMods = {}
local skillArray = {}
local skillIconArray = {}
local skillIconArray = {}
for j, skillID in pairs(cons.skills) do
for j, skillID in ipairs(cons.skills) do
local skill = SkillData.Skills[skillID + 1]
table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'}))
table.insert(skillArray, skill)
table.insert(skillIconArray, Icons.Icon({skill.name, type='skill'}))
--Building the list of Standard modifiers:
for k, modName in pairs(cons.standardModifiers[j]) do
local modBaseName, modText, sign, isNegative, unsign, modBase = Constants.getModifierDetails(modName)
local modVal = (Shared.contains(modText, '{SV0}') and {skillID, maxModifier}) or maxModifier
table.insert(standMods, Constants._getModifierText(modName, modVal, false))
end
end
end
result = result..'||'..table.concat(skillIconArray, '<br/>')
result = result..'||'..table.concat(skillIconArray, '<br/>')
local standModsRaw = p._buildAstrologyModifierArray(cons, maxModifier, true, false, false)
local standMods = {}
--Building the list of Standard modifiers:
for j, modifier in ipairs(standModsRaw) do
table.insert(standMods, Constants._getModifierText(modifier[1], modifier[2], false))
end
result = result..'|| '..table.concat(standMods, '<br/>')
result = result..'|| '..table.concat(standMods, '<br/>')
--Building the list of all Unique Modifiers
--Building the list of all Unique Modifiers
local uModsRaw = p._buildAstrologyModifierArray(cons, maxModifier, false, true, false)
local uMods = {}
local uMods = {}
for j, modName in pairs(cons.uniqueModifiers) do
for j, modifier in ipairs(uModsRaw) do
--The most important thing we're getting here is the modText and modBase
table.insert(uMods, Constants._getModifierText(modifier[1], modifier[2], false))
--modText lets us check if this is a per-skill modifier or not
--modBase lets us check .isSkill, which are modifiers that we only use for skills with Mastery
local modBaseName, modText, sign, isNegative, unsign, modBase = Constants.getModifierDetails(modName)
if Shared.contains(modText, '{SV0}') then
for k, skill in pairs(skillArray) do
local skillID = cons.skills[k]
local useMod = true
if modBase.isSkill then
useMod = skill.hasMastery
end
if useMod then
table.insert(uMods, Constants._getModifierText(modName, {skillID, maxModifier}, false))
end
end
else
table.insert(uMods, Constants._getModifierText(modName, maxModifier, false))
end
end
end
result = result..'||'..table.concat(uMods, '<br/>')
result = result..'||'..table.concat(uMods, '<br/>')