Module:Rites

local p = {}

function p.list(frame) local rites = mw.loadData("Module:Rites/data") local aspectsData = mw.loadData("Module:Aspects/data")

local intercaleRiteId = "riteconsumetoolingredientfollowerinfluence" local filteredRites = {} for k, v in pairs(rites) do       if k ~= intercaleRiteId then table.insert(filteredRites, v)       end end

table.sort(       filteredRites,        function(a, b)            return a.slots[2].required[1] > b.slots[2].required[1]        end    )

local t = {} local function renderRite(rite) table.insert(t, "|-") table.insert(t, "!" .. rite.label) table.insert(t, string.format("|", rite.label)) local i = 0 for _, slot in ipairs(rite.slots) do           i = i + 1 if slot.consumes then table.insert(t, '|style="background-color:#b13817"|') elseif slot.required[1] == "desire" then table.insert(t, '|style="background-color:#030e25"|') else table.insert(t, "|") end for _, aspect in ipairs(slot.required) do               table.insert(t, string.format("%s ", aspectsData[aspect].label)) end end end

table.insert(t, '{| class="wikitable"') for _, rite in ipairs(filteredRites) do       renderRite(rite) end renderRite(rites[intercaleRiteId]) table.insert(t, "|}")

return table.concat(t, "\n") end

return p