Module:Sandbox/SkillTree
Documentation for this module may be created at Module:Sandbox/SkillTree/doc
local p = {}
local Constants = require('Module:Constants')
local Num = require('Module:Number')
local Shared = require('Module:Shared')
local Common = require('Module:Common')
local GameData = require('Module:GameData')
local Modifiers = require('Module:Modifiers')
local Skills = require('Module:Skills')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local function deepPrint(tbl, indent)
if not indent then indent = 0 end
for k, v in pairs(tbl) do
local formatting = string.rep(" ", indent) .. k .. ": "
if type(v) == "table" then
mw.log(formatting)
deepPrint(v, indent + 1)
else
mw.log(formatting .. tostring(v))
end
end
end
function p.printSkillTrees()
local skillTrees = GameData.skillData.Agility.skillTrees
if not skillTrees then
mw.log("No skill trees found.")
return
end
mw.log("Skill Trees for Agility:")
for _, skillTree in ipairs(skillTrees) do
mw.log("------------------------------")
mw.log("Skill Tree ID: " .. skillTree.id)
mw.log("Skill Tree Name: " .. skillTree.name)
mw.log("Points Available: " .. (skillTree.points or "N/A"))
mw.log("Number of Nodes: " .. #skillTree.nodes)
-- Print information for each node in the skill tree
for _, node in ipairs(skillTree.nodes) do
mw.log(" Node ID: " .. node.id)
mw.log(" Node Name: " .. node.name)
mw.log(" Costs: " .. (node.costs.points or 0) .. " points")
mw.log(" Unlocked: " .. tostring(node.isUnlocked))
-- Print the node's modifiers
if node.modifiers then
mw.log(" Modifiers:")
deepPrint(node.modifiers, 2)
end
-- Print the node's parents (if any)
if node.parents then
mw.log(" Parents:")
for _, parentID in ipairs(node.parents) do
mw.log(" Parent Node ID: " .. parentID)
end
end
end
end
end
function p.getAllNodes()
local allNodes = {}
-- Iterate through all skills in the game
for skillName, skillData in pairs(GameData.skillData) do
local skillTrees = skillData.skillTrees
if skillTrees then
-- Iterate over each skill tree within the skill
for _, skillTree in ipairs(skillTrees) do
-- Iterate over each node within the skill tree
for _, node in ipairs(skillTree.nodes) do
table.insert(allNodes, node)
end
end
end
end
return allNodes
end
return p