Anonymous

Module:Skills/Gathering: Difference between revisions

From Melvor Idle
_buildAstrologyConstellationTable: Include mastery level requirements against each star/set of modifiers
(_buildAstrologyConstellationTable: Temporary fix following change to Skills._buildAstrologyModifierArray until this function's output is modified)
(_buildAstrologyConstellationTable: Include mastery level requirements against each star/set of modifiers)
Line 641: Line 641:


function p._buildAstrologyConstellationTable()
function p._buildAstrologyConstellationTable()
local result = '{|class="wikitable sortable stickyHeader"'
local resultPart = {}
result = result..'\r\n|- class="headerRow-0"'
table.insert(resultPart, '{|class="wikitable sortable stickyHeader"')
result = result..'\r\n!colspan="2"|Constellation!!'..Icons.Icon({"Astrology", type='skill', notext='true'})..' Level'
table.insert(resultPart, '\n|- class="headerRow-0"')
result = result..'!!XP!!Skills!!Standard Modifiers!!Unique Modifiers'
table.insert(resultPart, '\n!rowspan="2" colspan="2"|Constellation!!rowspan="2"| ' .. Icons.Icon({"Astrology", type='skill', notext='true'}) .. ' Level')
table.insert(resultPart, '!!rowspan="2"| XP!!rowspan="2"| Skills!!colspan="2"| Standard Stars!!colspan="2"| Unique Stars')
table.insert(resultPart, '\n|- class="headerRow-1"')
table.insert(resultPart, string.rep('\n! ' .. Icons.Icon({'Mastery', notext=true}) .. 'Level\n! Modifiers', 2))


for i, cons in ipairs(SkillData.Astrology.recipes) do
for i, cons in ipairs(SkillData.Astrology.recipes) do
-- Generate the list of modifiers first for the purpose of determining the
-- the number of rows required to display all stars
local modTypes = { 'standard', 'unique' }
local modsRaw = {
["standard"] = Skills._buildAstrologyModifierArray(cons, nil, true, false, false, false),
["unique"] = Skills._buildAstrologyModifierArray(cons, nil, false, true, false, false)
}
-- Building the list of standard & unique modifiers
local mods = {}
local modLevels = {}
local maxRows = 1
for j, modType in ipairs(modTypes) do
mods[modType] = {}
modLevels[modType] = {}
for k, modifier in ipairs(modsRaw[modType]) do
local masteryLevel = modifier.group
if mods[modType][masteryLevel] == nil then
mods[modType][masteryLevel] = {}
table.insert(modLevels[modType], masteryLevel)
end
local modMagnitude = type(modifier[2]) == 'table' and {modifier[2]} or modifier[2]
table.insert(mods[modType][masteryLevel], Constants._getModifierText(modifier[1], modMagnitude, false))
end
table.sort(modLevels[modType])
local typeCount = Shared.tableCount(modLevels[modType])
if typeCount > maxRows then
maxRows = typeCount
end
end
local name = cons.name
local name = cons.name
result = result..'\r\n|-'
local rowSpan = (maxRows > 1 and 'rowspan="' .. maxRows .. '"') or ''
result = result..'\r\n|data-sort-value="'..name..'"|'..Icons.Icon({name, type='constellation', size='50', notext=true})
table.insert(resultPart, '\n|-')
result = result..'|| ' .. Icons.getExpansionIcon(cons.id) .. name
table.insert(resultPart, '\n|' .. rowSpan .. ' data-sort-value="' .. name .. '"| ' .. Icons.Icon({name, type='constellation', size='50', notext=true}))
result = result..'||'..cons.level..'||'..cons.baseExperience
table.insert(resultPart, '\n|' .. rowSpan .. '| ' .. Icons.getExpansionIcon(cons.id) .. name)
table.insert(resultPart, '\n|' .. rowSpan .. ' style="text-align:right"| ' .. cons.level)
table.insert(resultPart, '\n|' .. rowSpan .. ' style="text-align:right"| ' .. cons.baseExperience)


local skillIconArray = {}
local skillIconArray = {}
Line 657: Line 692:
table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'}))
table.insert(skillIconArray, Icons.Icon({Constants.getSkillName(skillID), type='skill'}))
end
end
result = result..'||'..table.concat(skillIconArray, '<br/>')
table.insert(resultPart, '\n|' .. rowSpan .. '| ' .. table.concat(skillIconArray, '<br/>'))


--Adding a function that converts an array of connected bonuses into text [Falterfire 22/10/27]
-- Generate table text for standard & unique modifiers
local groupedModsToText = function(allMods)
for row = 1, maxRows, 1 do
local outArray = {}
for j, modType in ipairs(modTypes) do
for i, group in pairs(allMods) do
local masteryLevel = (modLevels[modType] ~= nil and modLevels[modType][row]) or nil
local groupTxt = table.concat(group, ' & ')
if masteryLevel ~= nil then
table.insert(outArray, groupTxt)
table.insert(resultPart, '\n|style="text-align:right"| ' .. masteryLevel)
table.insert(resultPart, '\n| ' .. table.concat(mods[modType][masteryLevel], '<br/>'))
else
table.insert(resultPart, '\n|colspan="2" class="table-na"| ')
end
end
return table.concat(outArray, '<br/>')
end
end
 
if row < maxRows then
local standModsRaw = Skills._buildAstrologyModifierArray(cons, nil, true, false, false, false)
table.insert(resultPart, '\n|-')
local standMods = {}
end
--Building the list of Standard modifiers:
for j, modifier in ipairs(standModsRaw) do
local modMagnitude = type(modifier[2]) == 'table' and {modifier[2]} or modifier[2]
local groupNum = modifier.group
if standMods[groupNum] == nil then standMods[groupNum] = {} end
table.insert(standMods[groupNum], Constants._getModifierText(modifier[1], modMagnitude, false))
end
result = result..'|| '..groupedModsToText(standMods)
 
--Building the list of all Unique Modifiers
local uModsRaw = Skills._buildAstrologyModifierArray(cons, nil, false, true, false, false)
local uMods = {}
for j, modifier in ipairs(uModsRaw) do
local modMagnitude = type(modifier[2]) == 'table' and {modifier[2]} or modifier[2]
local groupNum = modifier.group
if uMods[groupNum] == nil then uMods[groupNum] = {} end
table.insert(uMods[groupNum], Constants._getModifierText(modifier[1], modMagnitude, false))
end
end
result = result..'|| '..groupedModsToText(uMods)
end
end
result = result..'\r\n|}'
table.insert(resultPart, '\n|}')


return result
return table.concat(resultPart)
end
end