Module:Weapon

local p = {} local gameShortened = require("Module:GameShortened")

-- Local function for switch-like behavior to get full name local function getFullName(name) local case_table = { ["Bomb Rush"] = "Bomb Rush Splat Bomb", ["Bomb Rush (Burst Bomb)"] = "Bomb Rush Burst Bomb", ["Bomb Rush (Splat Bomb)"] = "Bomb Rush Splat Bomb", ["Bomb Rush (Suction Bomb)"] = "Bomb Rush Suction Bomb", ["Bomb Rush (Seeker)"] = "Bomb Rush Seeker", ["Bomb Launcher"] = "Splat-Bomb Launcher", ["Hero Gear"] = "Hero Shot Level 1", ["?"] = "Random", ["??"] = "Random 2", ["Unknown"] = "Not Found" }   return case_table[name] or name end

-- Local function for switch-like behavior to get link local function getLink(name, gameShort) -- If name starts with Bomb Rush if name:find("^Bomb Rush") then return "Bomb Rush" end

local case_table = { ["Bomb Launcher"] = "Splat-Bomb Launcher", ["Smallfry"] = "Smallfry (character)|Smallfry", ["Unarmed"] = "List of unarmed missions", ["?"] = gameShort == "S3" and "Salmon_Run_Next_Wave#Wildcard_rotation|Random" or "Salmon_Run#Wildcard_rotation|Random", ["??"] = gameShort == "S3" and "Salmon_Run_Next_Wave#Wildcard_rotation|Random Rare" or "Salmon_Run#Rare_weapon-only_rotation|Random Rare" }   return case_table[name] or name end

local function extractArg(args, namedKey, positionalIndex, defaultValue) return args[namedKey] or args[positionalIndex] or defaultValue end

function p.main(frame) -- Extract args from frame local parentArgs = frame:getParent.args local icononly = parentArgs['icononly'] or parentArgs[4] == "icononly" or parentArgs[5] == "icononly" or false local size = parentArgs['size'] or                 (parentArgs[4] ~= "icononly" and parentArgs[4]) or                  (parentArgs[5] ~= "icononly" and parentArgs[5]) or "24"

local args = { game = extractArg(parentArgs, 'game', 1, ""), category = extractArg(parentArgs, 'category', 2, ""), name = extractArg(parentArgs, 'name', 3, ""), icononly = icononly, size = size, variant = extractArg(parentArgs, 'var', nil, "") }

return p.getWeapon(args) end

-- Main function function p.getWeapon(args) local gameShort = gameShortened.getGame(args.game)

-- Construct the file name using getFullName local fileName = string.format("%s_Weapon_%s_%s%s.png", gameShort, args.category, getFullName(args.name), args.variant ~= "" and ("_" .. args.variant) or "")

-- Construct the output local output = string.format('', fileName, args.size, getLink(args.name, gameShort))

if not args.icononly then -- Add textual representation output = output .. " " .. getLink(args.name, gameShort) .. "" end

return output end

return p