Module:SalmonRunWildCard

local p = {} local weaponModule = require('Module:Weapon') -- rares are in order of release; needed for correct "Any" handling local grizzcoRares = {"Grizzco Blaster", "Grizzco Brella", "Grizzco Charger", "Grizzco Slosher", "Grizzco Stringer", "Grizzco Splatana", "Grizzco Dualies", ["Grizzco Blaster"]=1, ["Grizzco Brella"]=2, ["Grizzco Charger"]=3, ["Grizzco Slosher"]=4, ["Grizzco Stringer"]=5, ["Grizzco Splatana"]=6, ["Grizzco Dualies"]=7 }

function p.main(frame) -- Pull out args from frame local args = frame:getParent.args -- Pass to getRow return p.getRow(args) end

-- Determine if the row should be included based on rare_weapon and rare_weapon_filter local function shouldIncludeRow(rare_weapon, rare_weapon_filter, available_rares, number_of_rares) return rare_weapon_filter == nil or rare_weapon_filter == "" or rare_weapon_filter == rare_weapon or (available_rares[rare_weapon_filter] ~= nil and available_rares[rare_weapon_filter] <= number_of_rares) end

function p.getRow(args) local number_of_rares = tonumber(args["number_of_rares"]) or #grizzcoRares -- Default to half the length of the grizzcoRares array/map local rare_weapon = args["rare_weapon"] or "Any" local available_rares = {} if rare_weapon == "Any" then available_rares = grizzcoRares elseif rare_weapon == "Multiple" then local n = 1 for i in string.gmatch(args["available_rares"], "Grizzco [%a]*") do -- Match Grizzco followed by a single space followed by letters table.insert(available_rares, i)			available_rares[i] = n -- Map representation n = n + 1 end end local rare_weapon_filter = args["rare_weapon_filter"] -- or nil local game = args["game"] or "S2" local bigrun = args["bigrun"] and args["bigrun"] ~= "" or false local stage = args["stage"] or ""

if shouldIncludeRow(rare_weapon, rare_weapon_filter, available_rares, number_of_rares) then local row = {}

table.insert(row, "|-") table.insert(row, "|" .. args["time"]) table.insert(row, "|" .. stage .. "" .. (bigrun and " (Big Run)" or ""))

-- Insert weapon cells here for i = 1, 4 do           local weapon_args = { game = game, category = "Main", name = args["weapon_"..i], icononly = "icononly" }           table.insert(row, "|" .. weaponModule.getWeapon(weapon_args)) end

-- If rare_weapon is Any, list all available grizzco weapons, if rare_weapon is Multiple, list all weapons in available_rares, otherwise just list rare_weapon rares_cell = {} if rare_weapon == "Any" then for i = 1, math.min(number_of_rares, #grizzcoRares) do -- Loop only up to number_of_rares or the total available, whichever is smaller local weapon_args = { game = game, category = "Main", name = available_rares[i], icononly = "icononly" }               table.insert(rares_cell, weaponModule.getWeapon(weapon_args)) end table.insert(rares_cell, "Any") elseif rare_weapon == "Multiple" then for i = 1, number_of_rares do               local weapon_args = { game = game, category = "Main", name = available_rares[i], icononly = "icononly" }               table.insert(rares_cell, weaponModule.getWeapon(weapon_args)) end table.insert(rares_cell, "Multiple") elseif rare_weapon == "TBA" then table.insert(rares_cell, "TBA") else local weapon_args = { game = game, category = "Main", name = rare_weapon }           table.insert(rares_cell, weaponModule.getWeapon(weapon_args)) end table.insert(row, "|" .. table.concat(rares_cell, " ") .. "\n") return table.concat(row, "\n") else return "" end end

return p