Module:UtilsWeapons

local p = {} local utilsDisplay = require("Module:UtilsDisplay") local utilsIcons = require("Module:UtilsIcons") local utilsItems = require("Module:UtilsItems") local utilsCargo = require("Module:UtilsCargo")

function p.GetWeapon(weaponName) local query = {tables = 'Weapons', fields = { {name = "name", type = "String"}, {name = "type", type = "String"}, {name = "level", type = "Integer"}, {name = "rarity", type = "String"}, {name = "description", type = "String"}, {name = "random_elements", type = "Boolean"}, {name = "AP_cost", type = "Integer"}, {name = "attack_range", type = "Integer"}, {name = "summary", type = "List of String"}, {name = "critical_summary", type = "List of String"}, },   			args = { where = "name = '" .. weaponName .. "'",   			}    			}    local results = utilsCargo.Query(query)

return results[1] end

function p._DisplayDetails(frame) local args = frame:getParent.args return p.DisplayDetails(args[1]) end

function p.DisplayDetails(weaponName) local weapon = p.GetWeapon(weaponName) local result = mw.html.create("div") :addClass("weapon-details-container") :node(mw.html.create("div")			:addClass("weapon-details-name")			:wikitext(weapon["name"])) :node(mw.html.create("div")			:addClass("weapon-details-info")			:wikitext("Lvl." .. weapon["level"] .. " " .. weapon["rarity"] .. " " .. weapon["AP_cost"] .. utilsIcons.Display("Action Point") .. " " .. weapon["attack_range"] .. utilsIcons.Display("Range") )) :node(utilsItems.DisplayItem(weapon["name"])) :node(mw.html.create("div")			:addClass("weapon-details-type")			:wikitext("[" .. weapon["type"] .. "]"))		:node(mw.html.create("div")			:addClass("weapon-details-description")			:wikitext('"' .. weapon["description"] .. '"')) local effectTabs = { {name = "Summary", effects = weapon["summary"]}, {name = "Critical", effects = weapon["critical_summary"]} }		local effects = utilsDisplay.DisplayEffectTables(effectTabs) result:node(effects) return result end

return p