Module:Classes

-- local p = {}

local data = require("Module:Classes/Data") local data_abilities = require("Module:Abilities/Data") local data_weapons = require("Module:Weapons/Data")

- Class Infobox - local infobox_template = [=[

]=]

function p.Infobox(frame) local class_name = frame.args[1] or mw.title.getCurrentTitle.text local class = data.classes[class_name] if class == nil then return "Class infobox data not found for \"" .. class_name .. "\". Check the parameter or add the data to Module:Classes/Data." end local category = "" return frame:preprocess(string.format(infobox_template, class_name, class_name, class.Passive, Abilities(class_name), Weapon(class_name), class.Description, category )) end

- Class List - function ClassList local classes = {} for class_name, class in pairs(data.classes) do   class.Name = class_name table.insert(classes, class) end table.sort(classes, function(a, b) return a.Name < b.Name end) return classes end

- Abilities - function Abilities(class) local abilities = {} for ability_name, ability in pairs(data_abilities.abilities) do   if ability.Class == class then table.insert(abilities, "" .. ability_name .. "") end end table.sort(abilities, function(a, b) return a < b end) return table.concat(abilities, " ") end

- Weapon - function Weapon(class) local weapon for weapon_name, weapon in pairs(data_weapons.weapons) do   if weapon.Class == class then return " " .. weapon_name .. "" end end end

- Class Table - local classes_table_head = [=[ {| class="article-table sortable" style="text-align:center;font-size:75%" width="100%" ! style="text-align:center" class="unsortable" | Icon ! style="text-align:center" | Class ! style="text-align:center" class="unsortable" | Passive ! style="text-align:center" class="unsortable" | Abilities ! style="text-align:center" class="unsortable" | Weapon ! style="text-align:center" class="unsortable" | Description ]=]

local classes_table_row = [=[ ]=]
 * style="background-color:#CCCCCC" | Class_Icon_%s.png
 * %s
 * %s
 * %s
 * %s
 * %s
 * %s

function p.List(frame) local list = classes_table_head for _, class in pairs(ClassList) do   list = list .. string.format(classes_table_row,     class.Name,      class.Name,      class.Name,      class.Passive,      Abilities(class.Name),      Weapon(class.Name),      class.Description    ) end list = list .. "|}" return list end

return p --