Documentation for this module may be created at Module:Relics/doc
--Relic equivalent of Module:Cards
--Based on the data in Module:Relics/data - If the information is wrong, edit it there
local p = {}
local RelicData = mw.loadData( 'Module:Relics/data' )
local Shared = require( 'Module:Shared' )
local Keywords = require( 'Module:Keywords' )
function p.getRelic(relicName)
--If no name is sent, just return nil
if(relicName == nil or relicName == "") then return nil end
--Loop through all cards, return if the key or the name match
for i, relic in pairs(RelicData["Relics"]) do
if relic.Name == relicName then return relic
elseif relic.ID == relicName then return relic end
end
--If not found, return nil
return nil
end
function getValue(theRelic, valName, asString)
if(asString == nil) then asString = false end
if(valName == nil or valName == "") then
return "ERROR: No value chosen"
else
valName = string.upper(valName)
end
local result = nil
if(valName == 'NAME') then
result = theRelic.Name
elseif(valName == 'NAMELINK') then
if(theRelic.Link ~= nil) then
result = '[['..theRelic.Link..'|'..theRelic.Name..']]'
else
result = theRelic.Name
end
elseif(valName == "DESCRIPTION") then
result = theRelic.Description
elseif(valName == "FULLDESCRIPTION") then
result = theRelic.Description
if(result ~= nil) then
result = Keywords.FillIcons(result)
result = Keywords.FillKeywords(result)
end
elseif(valName == "FLAVOR") then
result = theRelic.Flavor
elseif(valName == "IMAGE") then
result = theRelic.Image
elseif(valName == 'RARITY') then
result = theRelic.Rarity
elseif(valName == "CHARACTER") then
result = theRelic.Character
elseif(valName == "EVENT") then
result = theRelic.EventName
elseif(valName == 'EVENTICON') then
result = theRelic.EventIcon
elseif(valName == "EVENT02") then
result = theRelic.Event02Name
elseif(valName == 'EVENTICON02') then
result = theRelic.Event02Icon
elseif(valName == 'TOOLTIP') then
local name = getValue(theRelic, "NAME")
local rarity = getValue(theRelic, "RARITY")
local text = getValue(theRelic, "DESCRIPTION")
local flavor = getValue(theRelic, "FLAVOR")
result = ''
result = result..name
if rarity ~= nil then
result = result..' ('..rarity..')'
end
if text ~= nil then
--Add in Icons, but don't include tooltips
result = result..'\\n'..text
end
elseif(valName == 'TOOLTIP2') then
local image = getValue(theRelic, "IMAGE")
local name = getValue(theRelic, "NAME")
local text = getValue(theRelic, "DESCRIPTION")
local flavor = getValue(theRelic, "FLAVOR")
result = ''
if image ~= nil then
result = result..'[[File:'..image..'|link='..name..'|x40px]] '
end
result = result..name
if text ~= nil then
--Add in Icons, but don't include tooltips
text = Keywords.FillIcons(text, "NO")
result = result..':<br>'..text
end
if(flavor ~= nil) then
result = result.."<br>''"..flavor.."''"
end
else
result = 'ERROR: No such value found'
end
if(asString and result == nil) then result = '' end
return result
end
function p.getValue(frame)
local RelicName = frame.args ~= nil and frame.args[1] or nil
local ValName = frame.args ~= nil and frame.args[2] or nil
if (RelicName == nil or RelicName == "") then return "ERROR: No relic name chosen" end
local TheRelic = p.getRelic(RelicName)
if(TheRelic == nil) then return nil end
return getValue(TheRelic, ValName, true)
end
function p._getRelicLink(RelicName, OverrideText, TypeOfDisplay)
if(RelicName == nil or RelicName == "") then return "ERROR: No relic name chosen" end
local TheRelic = p.getRelic(RelicName)
local image = getValue(TheRelic, 'Image')
local tooltip = getValue(TheRelic, 'Tooltip')
if(TheRelic == nil) then return nil end
local relicLink = ''
if(OverrideText == nil or OverrideText == '') then
relicLink = getValue(TheRelic, 'NameLink')
if(relicLink == "Golden Idol") then
relicLink = 'Golden Idol (Relic)|Golden Idol'
end
relicLink = '[['..relicLink..']]'
else
relicLink = getValue(TheRelic, 'NameLink')
if(relicLink == "Golden Idol") then
relicLink = 'Golden Idol (Relic)'
end
relicLink = '[['..relicLink..'|'..OverrideText..']]'
end
local result = ''
if(image ~= nil) then
result = '[[File:'..image..'|21x23px|middle]] '
result = result..' '..relicLink
end
if (TypeOfDisplay == "thumb" or TypeOfDisplay == "thumbnail" or TypeOfDisplay == "Thumb" or TypeOfDisplay == "Thumbnail" or TypeOfDisplay == "t" or TypeOfDisplay == "T") then
relicLink = getValue(TheRelic, 'NameLink')
if(relicLink == "Golden Idol") then
relicLink = 'Golden Idol (Relic)'
end
result = '[[File:'..image..'|link='..relicLink..'|67x73px|middle]]'
elseif (TypeOfDisplay == "menu" or TypeOfDisplay == "Menu" or TypeOfDisplay == "M") then
relicLink = getValue(TheRelic, 'NameLink')
if(relicLink == "Golden Idol") then
relicLink = 'Golden Idol (Relic)'
end
result = '[[File:'..image..'|link='..relicLink..'|36x34px|middle]]'
end
result = '<span class = "basic-tooltip" title="'..tooltip..'">'..result..'</span>'
return result
end
function p._getRelicTooltip(TheRelic)
if(TheRelic == nil or TheRelic == "") then return "ERROR: No relic name chosen" end
local TheRelic = p.getRelic(TheRelic)
local name = getValue(TheRelic, 'Name')
local image = getValue(TheRelic, 'Image')
local rarity = getValue(TheRelic, 'Rarity')
local character = getValue(TheRelic, 'Character')
local event = getValue(TheRelic, 'Event')
local eventIcon = getValue(TheRelic, 'EventIcon')
local event02 = getValue(TheRelic, 'Event02')
local event02Icon = getValue(TheRelic, 'EventIcon02')
--Rarity Colors
--Starter
if (rarity == "Starter") then
rarity = '{{Color|#b0b0e8|Starter}}'
--Common
elseif (rarity == "Common") then
rarity = '{{Color|Grey|Common}}'
--Uncommon
elseif (rarity == "Uncommon") then
rarity = '{{Color|skyBlue|Uncommon}}'
--Rare
elseif (rarity == "Rare") then
rarity = '{{Color|gold|Rare}}'
--Boss
elseif (rarity == "Boss") then
rarity = '{{Color|salmon|Boss}}'
--Event
elseif (rarity == "Event") then
rarity = '{{Color|violet|Event}}'
--Shop
elseif (rarity == "Shop") then
rarity = '{{Color|lightGreen|Shop}}'
--Special
elseif (rarity == "Special") then
rarity = '{{Color|#b0b0e8|Special}}'
else
rarity = '{{Color|#b0b0e8|'..rarity..'}}'
end
--Character
if (character ~= nil) then
--Ironclad
if (character == "Ironclad") then
rarity = rarity..' • {{Color|indianRed|Ironclad}}'
--Silent
elseif (character == "Silent") then
rarity = rarity..' • {{Color|mediumSeaGreen|Silent}}'
--Defect
elseif (character == "Defect") then
rarity = rarity..' • {{Color|cornFlowerBlue|Defect}}'
--Watcher
elseif (character == "Watcher") then
rarity = rarity..' • {{Color|mediumPurple|Watcher}}'
--Other
else
rarity = rarity..' • {{Color|lavender|'..character..'}}'
end
end
--Event
if (event ~= nil) then
--Event Icon
if (eventIcon ~= nil) then
rarity = rarity..' • [[[[File:'..eventIcon..'|20px]] '
end
--Event Name
rarity = rarity..'{{Color|rosybrown|'..event..'}}'
end
--Additional Event
if (event02 ~= nil) then
rarity = rarity..' / '
--Event Icon
if (eventIcon02 ~= nil) then
rarity = rarity..'[[[[File:'..event02Icon..'|20px]] '
end
--Event Name
rarity = rarity..'{{Color|rosybrown|'..event02..'}}'
end
local text = getValue(TheRelic, "DESCRIPTION")
local flavor = getValue(TheRelic, "FLAVOR")
if(TheRelic == nil) then return nil end
local result = '{| style="word-break:break-all; border: 2px solid #5959c0; background-color: #2C2A4E; border-radius: 10px; width: 600px; padding: 10px 20px 10px 20px"'
if(image ~= nil) then
result = result..'|rowspan="2" style="width: 10%;"|[[File:'..image..'|70px]]'
else
result = '|rowspan="2" style="width: 10%;"'
end
if(TheRelic ~= nil) then
result = result..'|colspan="2" |<div style="font-size: 17px;">'..name..'</div>'
else
result = '{{Relic-Tooltip||'
end
if(rarity ~= nil) then
result = result..rarity..'|'
else
result = '{{Relic-Tooltip|||'
end
if(text ~= nil) then
result = result..text..'|'
else
result = '{{Relic-Tooltip||||'
end
if(flavor ~= nil) then
result = result..flavor
else
result = '{{Relic-Tooltip||||'
end
result = result..'|}'
return result
end
function p.getRelicLink(frame)
local relicName = frame.args ~= nil and frame.args[1] or nil
local text = frame.args ~= nil and frame.args.text or nil
local displayType = frame.args ~= nil and frame.args.displayType or nil
return p._getRelicLink(relicName, text, displayType)
end
function p.getRelicTooltip(frame)
local relicName = frame.args[1] or frame.args["relic"] or nil
return p._getRelicTooltip(relicName)
end
function p._getRelicLink2(RelicName, OverrideText, TypeOfDisplay)
if(RelicName == nil or RelicName == "") then return "ERROR: No relic name chosen" end
local TheRelic = p.getRelic(RelicName)
if(TheRelic == nil) then return nil end
local relicLink = ''
if(OverrideText == nil or OverrideText == '') then
relicLink = getValue(TheRelic, 'NameLink')
else
local link = getValue(TheRelic, 'Link')
relicLink = '[['..link..'|'..OverrideText..']]'
end
local image = getValue(TheRelic, 'Image')
local result = '<div style="display:block;">'..getValue(TheRelic, 'Tooltip2')..'</div>'
return result
end
function p.getRelicLink2(frame)
local relicName = frame.args ~= nil and frame.args[1] or nil
local text = frame.args ~= nil and frame.args.text or nil
return p._getRelicLink2(relicName, text)
end
return p