Module:Sandbox/SkillTree

Revision as of 15:51, 30 August 2024 by Toadmilk (talk | contribs)

Documentation for this module may be created at Module:Sandbox/SkillTree/doc

local p = {}

local GameData = require('Module:GameData')
local SkillData = GameData.skillData

function p.getSkillTreeNodes(checkFunc)
    local nodes = {}
    
    for skillName, skillData in pairs(GameData.skillData) do
        local skillTrees = skillData.skillTrees
        if skillTrees then
            for _, skillTree in ipairs(skillTrees) do
                for _, node in ipairs(GameData.getEntities(skillTree.nodes, checkFunc)) do
                    local nodeCopy = {}
                    for k, v in pairs(node) do
                        nodeCopy[k] = v
                    end

                    nodeCopy.skillName = skillName

                    table.insert(nodes, nodeCopy)
                end
            end
        end
    end
    return nodes
end

return p