Module:Skill level table

local util = require('Module:Util') local p = {}

function p.skillLevelTable(frame) local args = frame.args return p._skillLevelTable(args[1]) end

-- Print out the skill level table for a specified skill -- This includes the effects which are upgraded at every skill level -- eg. Level 1 81% Damage, Level 2 86% Damage, etc. function p._skillLevelTable(skill) -- Get the number of effects a skill has -- This determines how many effect columns we need to make in the table local numSkillEffects = util.getNumberOfEffects(skill)

-- Get the max number of levels this skill can level up to -- This determines how many rows we need to make in the table local numLevels = util.getSkillMaxLevel(skill)

-- Create the table with the correct class and CSS styling local tbl = mw.html.create('table') :addClass('wikitable') :css('width', '100%') :css('text-align', 'center')

-- Create the table headers tbl:tag('th') :wikitext('Level') :css('width', '40px') tbl:tag('th') :wikitext('Class Level Requirement') :css('width', '50px') -- Create the effect headers depending on how many skill effects were queried for i=1,numSkillEffects do   -- Query for the Effect name local skillEffectDescription = util.getSkillEffectDescription(skill, i)   tbl:tag('th') :wikitext(skillEffectDescription) end

-- Create the table rows for each skill level for i=1,numLevels do   tbl = createSkillLevelRow(skill, i, numSkillEffects, tbl) end

-- Return the table return tostring(tbl) end

-- This function creates the table rows for each skill level. It includes: --  * Skill level --  * Character level requirement to access this level --  * The numbers for effects which change level to level (eg. Damage %) function createSkillLevelRow(skill, level, numSkillEffects, tbl) -- Create the table row in the table local tr = tbl:tag('tr')

-- Add the Skill Level Table Cell tr:tag('td') :wikitext(level)

-- Add the Level Requirement Table Cell local levelReq = util.getSkillLevelRequirement(skill, level) tr:tag('td') :wikitext(levelReq)

-- Add the Skill Effects Table Cell(s) for i=1,numSkillEffects do   local skillEffectValue = util.getSkillEffectValue(skill, level, i)    tr:tag('td') :wikitext(skillEffectValue) :css('color', '#007cff') :css('font-weight', 'bold') end

-- Return the table with the newly created row return tbl end

return p