The site was updated to MediaWiki 1.43. If anything looks broken or there are glitches, report on the talk page or Discord in #wiki-support.
Module:SS Medals
Documentation for this module may be created at Module:SS Medals/doc
local p = {}
-- Helper function to determine the correct class value
local function getClass(data, id)
local class = data[id]["class"]
if type(class) == "string" then
return class
elseif type(class) == "table" and #class == 1 then
return class[1]
else
return "None"
end
end
function p.getData(frame)
local data = mw.loadJsonData('JoJo Wiki:SS Medals')
local id = frame.args[1]
local param = frame.args[2]
-- Check if data for the given ID exists
if not data[id] then
return "N/A"
end
-- Handle image file name generation and specific class-based requests
if param == "frameImage" or param == "ability" then
local rarity = data[id]["rarity"] or "None"
local class = getClass(data, id)
local fileBase = (param == "frameImage") and "Unit_Frame" or "Unit_Ability"
return string.format("%s_%s_%s.png", fileBase, rarity, class)
elseif param == "coinImage" then
return string.format("Unit_Coin_%s.png", data[id]["rarity"] or "None")
elseif param == "bgImage" then
return string.format("Unit_bg_%s.png", data[id]["rarity"] or "None")
elseif param == "class" then
return getClass(data, id)
-- Handling specific requests for 'character' parameters
elseif param:match("^character%d+$") then
local index = tonumber(param:match("%d+"))
local characters = data[id]["character"]
if characters and type(characters) == "table" and characters[index] then
return characters[index]
else
return "None"
end
elseif param == "character" then
if type(data[id]["character"]) == "table" then
if #data[id]["character"] == 1 then
return data[id]["character"][1] -- Return the single character if there's only one
else
return table.concat(data[id]["character"], ", ") -- Concatenate with comma if multiple
end
elseif type(data[id]["character"]) == "string" then
return data[id]["character"]
else
return "None"
end
else
-- Standard parameter handling
local value = data[id][param]
if value then
if type(value) == "table" then
return table.concat(value, ", ")
else
return tostring(value)
end
else
return "None"
end
end
end
return p