Module:Card: Difference between revisions

No edit summary
right, trimmed out most of the garbage
Line 7: Line 7:


local allData = {
local allData = {
{'Agent', mw.loadData('Module:CentralData/Agents')},
--{'Neighbor', mw.loadData('Module:CentralData/Neighbors')},
{'W-Engine', mw.loadData('Module:CentralData/W-Engines')},
{'Creature', mw.loadData('Module:CentralData/Creatures')},
{'Drive Disc', mw.loadData('Module:CentralData/Drive Discs')},
--{'Furniture', mw.loadData('Module:CentralData/Furniture')},
{'Bangboo', mw.loadData('Module:CentralData/Bangboo')},
{'Enemy', mw.loadData('Module:CentralData/Enemies')},
{'Resonium', mw.loadData('Module:CentralData/Resonia')},
{'Item', mw.loadData('Module:CentralData/Items')},
{'Companion', mw.loadData('Module:CentralData/Companions')},
{'Outfit', mw.loadData('Module:CentralData/Outfits')},
}
}


Line 33: Line 27:
-- Reset agent-specific data to prevent carry-over from previous cards
-- Reset agent-specific data to prevent carry-over from previous cards
local agRank, agAttribute, agSpecialty, bbRank, weRank, weSpecialty, outRank, notice = nil, nil, nil, nil, nil, nil, nil, nil
local agQuality, nbGalaxy, crQuality, crGalaxy, outQuality, notice = nil, nil, nil, nil, nil, nil
-- Caption Params:
-- Caption Params:
Line 50: Line 44:
-- Rank Param:
-- Rank Param:
local rank = args.rank or args.quality or args.rarity or nil
local quality = args.quality or args.rarity or nil
-- Try to get Rank From Data
-- Try to get Rank From Data
if lib.isEmpty(rank) and data then
if lib.isEmpty(quality) and data then
if data.rank then
if data.quality then
rank = data.rank
quality = data.quality
end
end
end
end
-- If rank is still empty, set it to "C"
-- If quality is still empty, set it to "Gray"
if lib.isEmpty(rank) then
if lib.isEmpty(quality) then
rank = 'C'  
quality = 'Gray'  
end
end
-- If rank contains a semicolon, then split and get first
-- If quality contains a semicolon, then split and get first
if string.find(rank, ";") then
if string.find(quality, ";") then
rank = array._main({
quality = array._main({
rank,
quality,
';',
';',
firstItemOnly = 1
firstItemOnly = 1
Line 73: Line 67:
end
end
-- Make sure rank is uppercase
-- Make sure quality is uppercase
rank = rank:upper()
quality = quality:upper()
-- Modifiers:
-- Modifiers:
Line 80: Line 74:
local isUp = args.UP or args.up or false
local isUp = args.UP or args.up or false
-- Attribute/specialty
-- Attribute/galaxy
local attribute = args.attr or args.attribute or nil
local galaxy = args.galaxy or nil
local specialty = args.spec or args.fightSpec or args.fs or nil
if lib.isEmpty(suffix) then
if lib.isEmpty(suffix) then
local lcType = type:lower()
local lcType = type:lower()
if (lcType == 'agent') then
if (lcType == 'neighbor') then
suffix = ' Icon'
suffix = ' Icon'
--Grabs Agent Rank, Attribute and Specialty from Data to display icons
--Grabs Agent Rank, Attribute and Specialty from Data to display icons
agRank = data['rank']
agQuality = data['quality']
agAttribute = data['attribute']
agAttribute = data['attribute']
agSpecialty = data['specialty']
nbGalaxy = data['galaxy']
--In Full-Size Card-Mode, if there is no specified text, Agents will default to using their full name displayed underneath.
--In Full-Size Card-Mode, if there is no specified text, Agents will default to using their full name displayed underneath.
Line 110: Line 103:
end
end
elseif (lcType == 'bangboo') then
elseif (lcType == 'creature') then
suffix = ' Icon'
suffix = ' Icon'
--Grabs Bangboo Rank from Data to display icons
--Grabs Creature Rank and Galaxy from Data to display icons
bbRank = data['rank']
crQuality = data['quality']
crGalaxy = data['galaxy']
elseif (lcType == 'w-engine') then
suffix = ' Icon'
--Grabs W-Engine Rank and Specialty from Data to display icons
weRank = data['rank']
weSpecialty = data['specialty']
elseif (lcType == 'enemy') then
suffix = '' --icon
enemyType = data and data['type'] or ''
enemyTier = data and data['tier'] or ''
enemyWeakness = data and data['weakness'] or ''
imageSize = lib.ternary(args.mini == '1', 48, 70)
elseif (lcType == 'drive disc') then
suffix = ' Icon'
elseif (lcType == 'npc') then
elseif (lcType == 'npc') then
suffix = ' Icon'
suffix = ' Icon'
elseif (lcType == 'outfit') then
elseif (lcType == 'clothing') then
suffix = ' Icon'
suffix = ' Icon'
--Grabs Outfit Rank from Data to display icons
--Grabs Outfit Rank from Data to display icons
outRank = data['rank']
outQuality = data['quality']
end
end
end
end
Line 151: Line 129:
local card_container = result:tag('div')
local card_container = result:tag('div')
:addClass('card-container')
:addClass('card-container')
:addClass('card-rank-' .. rank)
:addClass('card-quality-' .. quality)
if args.mini == "1" then
if args.mini == "1" then
Line 211: Line 189:
-- Attribute icon, applied automatically for agents or manually specified for anything else
-- Attribute icon, applied automatically for agents or manually specified for anything else
if args.mini ~= "1" then  -- Only display the icons if mini is not set to "1"
if args.mini ~= "1" then  -- Only display the icons if mini is not set to "1"
if ne(agRank) then
if ne(nbGalaxy) then
card_body:addClass('card-rank-' .. string.lower(agRank))
card_body:addClass('card-galaxy-' .. string.lower(nbGalaxy))
card_body:tag('span')
card_body:tag('span')
:addClass('card-icon-rank')
:addClass('card-icon-galaxy')
:wikitext('[[File:Icon AgentRank ', agRank, '.png|alt=', agRank, '|link=|20px]]')
:wikitext('[[File:Icon ', nbGalaxy, '.png|alt=', nbGalaxy, '|link=', nbGalaxy, '|20px]]')
end
end
if ne(bbRank) then
if ne(crGalaxy) then
card_body:addClass('card-rank-' .. string.lower(bbRank))
card_body:addClass('card-galaxy-' .. string.lower(crGalaxy))
card_body:tag('span')
card_body:tag('span')
:addClass('card-icon-rank')
:addClass('card-icon-galaxy')
:wikitext('[[File:Icon Bangboo Rank ', bbRank, '.png|alt=', bbRank, '|link=|20px]]')
:wikitext('[[File:Icon ', crGalaxy, '.png|alt=', crGalaxy, '|link=', crGalaxy, '|20px]]')
end
if ne(weRank) then
card_body:addClass('card-rank-' .. string.lower(weRank))
card_body:tag('span')
:addClass('card-icon-rank')
:wikitext('[[File:Icon AgentRank ', weRank, '.png|alt=', weRank, '|link=|20px]]')
end
if ne(agAttribute) then
card_body:addClass('card-attribute-' .. string.lower(agAttribute))
card_body:tag('span')
:addClass('card-icon-attribute')
:wikitext('[[File:Icon ', agAttribute, '.png|alt=', agAttribute, '|link=', agAttribute, '|20px]]')
end
if ne(agSpecialty) then
card_body:addClass('card-specialty-' .. string.lower(agSpecialty))
card_body:tag('span')
:addClass('card-icon-specialty')
:wikitext('[[File:Icon ', agSpecialty, '.png|alt=', agSpecialty, '|link=', agSpecialty, '|20px]]')
end
if ne(weSpecialty) then
card_body:addClass('card-specialty-' .. string.lower(weSpecialty))
card_body:tag('span')
:addClass('card-icon-specialty')
:wikitext('[[File:Icon ', weSpecialty, '.png|alt=', weSpecialty, '|link=', weSpecialty, '|20px]]')
end
if ne(outRank) then
card_body:addClass('card-rank-' .. string.lower(outRank))
card_body:tag('span')
:addClass('card-icon-rank')
:wikitext('[[File:Icon Item Rank ', outRank, '.png|alt=', outRank, '|link=|20px]]')
end
local cinema = args.cinema or args.c or nil
if ne(cinema) then
card_body:tag('span')
:addClass('card-cinema')
:addClass('cinema-' .. cinema)
:wikitext(' C', cinema)
card_body:addClass('card-with-cinema')
end
local phase = args.phase or args.p or nil
if ne(phase) then
card_body:tag('span')
:addClass('card-phase')
:addClass('phase-' .. phase)
:wikitext(' P', phase)
card_body:addClass('card-with-phase')
end
end
    local notice = args.notice or nil
    local notice = args.notice or nil
Line 275: Line 207:
:wikitext(notice)
:wikitext(notice)
    end
    end
if ne(enemyType) then
card_body:tag('span')
:addClass('card-icon-enemy-type')
:wikitext('[[File:', enemyType, ' Icon.png|alt=', enemyType, '|link=', enemyType, '|28px]]')
end
if ne(enemyWeakness) then
local weaknessContainer = card_body:tag('span')
:addClass('card-enemy-weaknesses')
for weakness in lib.gsplit(enemyWeakness, ';') do
weaknessContainer:wikitext('[[File:Icon ', weakness, '.png|16px|link=', weakness, '|Weak to ', weakness, ']]')
end
end
end
if ne(enemyTier) then
card_body:addClass('card-enemy card-enemy-' .. enemyTier:gsub(' ', ''))
end
end