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"}

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) return rare_weapon_filter == nil or rare_weapon_filter == "" or rare_weapon == "Any" or rare_weapon_filter == rare_weapon end

function p.getRow(args) local rare_weapon = args["rare_weapon"] or "Any" local rare_weapon_filter = args["rare_weapon_filter"] -- or nil local number_of_rares = tonumber(args["number_of_rares"]) or #grizzcoRares -- Default to the length of the grizzcoRares array 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) 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 multiple weapons, else list the given 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 = grizzcoRares[i], icononly = "icononly" }               table.insert(rares_cell, weaponModule.getWeapon(weapon_args)) end table.insert(rares_cell, "Any") 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