Aigis Wiki
Register
m (applying fixes for shengpu)
mNo edit summary
Line 239: Line 239:
 
out = out .. '<div>'
 
out = out .. '<div>'
 
out = out .. '<div class="unitcards-title'..bigname..'">'
 
out = out .. '<div class="unitcards-title'..bigname..'">'
out = out .. '<span'..name..'</span>'
+
out = out .. '<span>'..name..'</span>'
 
out = out .. '</div>'
 
out = out .. '</div>'
 
out = out .. '<div class="unitcards-icon">[[File:'..filepath..']]</div>'
 
out = out .. '<div class="unitcards-icon">[[File:'..filepath..']]</div>'

Revision as of 07:36, 29 February 2020

Documentation for this module may be created at Module:UnitCardsV2/doc

--Use: 
--{{UnitcardV2|name=|cc=|img=|level=|Skill=|CR=|aff=|note=|nickname=|title=}}
--ex: {{UnitcardV2|name=Machina|cc=AW2v2|level=54|Skill=SAW|aff=100|CR=20|note=Chem. E. Waifu}}
--Remember, prince and regular units are parsed differently
--Notes:
-- Added:
--  Note section
--  SAW icon in place of skill level
--  Nicknames (replace unit name with custom name)
--  Title (Replaces unit name with custom nickname; only works with Prince at the moment)
--  Prince unit (Formatting of prince name non standard)
--  Halloween season
--  Affection percent
-- Modified:
--  Collab unit event name added as a seasonal string
-- Bugs:
--  Bigname bug: bignames extend card by a couple pixels, breaking evenness
--  Custom titles broken for non-Prince units
-- Planned Additions:
--  Adjutant/Waifu icon
--  Script to make updating a list of cards easier
--  Kkentaro unit list to this/Shiny unitcard converter, and vice versa
--  Cleanup of code (better prince name handling, cost reduction database lookup, other database lookups)
local shiny = {}
function shiny.main(frame)
  local name, state, filepath, unit_level, skill_level, cost_reduction, scolor, season, bigname, note, nickname, event, affection
 
  local cctable = {
    ['base'] = '',
    ['cc'] = 'CC',
    ['aw'] = 'AW',
    ['aw2'] = 'AW2',
    ['aw2v1'] = 'AW2v1',
    ['aw2v2'] = 'AW2v2'}
 
  local colors = {
    ['swimsuit'] = 'cyan',
    ['dress'] = 'purple',
    ['bride'] = 'white;text-shadow: 0 0 6px #000000',
    ['school'] = 'gray',
    ["valentine's"] = 'pink',
    ["new year's"] = 'red',
    ['christmas'] = 'green',
    ['yukata'] = 'fuchsia',
    ['halloween'] = 'orange',
  }
  
  --Thanks for not standardizing the prince icon...
  
  local princeMap = {
      ['prince'] = 'Prince ',
      ['prince (aw)'] = 'Awakened Prince ',
      ['prince (awakened)'] = 'Awakened Prince ',
      ['prince (sacred equipment)'] = 'Awakened Prince ',
      ['prince (keraunos)'] = 'Prince (Keraunos) ',
      ['prince (shota)'] = 'Shota Prince ',
      ['prince (childhood)'] = 'Shota Prince ',
      ['prince (chibi)'] = 'Chibi Prince ',
      ['prince (desert)'] = 'Prince Desert ',
      ['prince (beast)'] = 'Prince Beast ',
      ['prince (giant)'] = 'Prince (Giant) ',
      ['prince (wind guardian)'] = 'Prince (Wind Guardian) ',
      ['prince (einherjar)'] = 'Prince (Einherjar) ',
      ['prince (dark)'] = 'Prince (Dark) ',
      ['prince (edgelord)'] = 'Prince (Dark) ',
      ['prince (hero)'] = 'Prince (Hero King) ',
      ['prince (hero king)'] = 'Prince (Hero King) ',
      ['prince (four gods)'] = 'Prince (Four Gods) ',
      ['prince (avatar)'] = 'Prince (Four Gods) '
  }
  
  local princeSpecial = {
      ['prince'] = '',
      ['prince (aw)'] = 'Awakened',
      ['prince (awakened)'] = 'Awakened',
      ['prince (sacred equipment)'] = 'Sacred Equipment',
      ['prince (keraunos)'] = 'Keraunos',
      ['prince (shota)'] = 'Shota',
      ['prince (childhood)'] = 'Childhood',
      ['prince (chibi)'] = 'Chibi',
      ['prince (desert)'] = 'Desert',
      ['prince (beast)'] = 'Beast',
      ['prince (giant)'] = 'Giant',
      ['prince (wind guardian)'] = 'Wind Guardian',
      ['prince (einherjar)'] = 'Einherjar',
      ['prince (dark)'] = 'Dark ',
      ['prince (edgelord)'] = 'Dark ',
      ['prince (hero)'] = 'Hero King ',
      ['prince (hero king)'] = 'Hero King ',
      ['prince (four gods)'] = 'Four Gods ',
      ['prince (avatar)'] = 'Four Gods '
  }
  
  local princeAW = {
      ['prince'] = '',
      ['prince (aw)'] = 'AW ',
      ['prince (awakened)'] = 'AW ',
      ['prince (sacred equipment)'] = 'AW ',
      ['prince (keraunos)'] = 'AW ',
      ['prince (shota)'] = '',
      ['prince (childhood)'] = '',
      ['prince (chibi)'] = '',
      ['prince (desert)'] = 'AW ',
      ['prince (beast)'] = 'AW ',
      ['prince (giant)'] = 'AW ',
      ['prince (wind guardian)'] = 'AW ',
      ['prince (einherjar)'] = 'AW ',
      ['prince (dark)'] = 'AW ',
      ['prince (edgelord)'] = 'AW ',
      ['prince (hero)'] = 'AW ',
      ['prince (hero king)'] = 'AW ',
      ['prince (four gods)'] = 'AW ',
      ['prince (avatar)'] = 'AW '
  }

  local sawIcon = '[[File:SAW_Icon.png|12px|link=]]'
 
  local isSaw = false
  
  note = ''
  local title = ''
  scolor = 'black'
 
  for arg, value in pairs(frame:getParent().args) do
  arg = arg:lower()
    if arg == 1 then name = value end
    if arg == 'name' then name = value end
    
    if arg == 2 then state = cctable[value:lower()] end
    if arg == 'state' then state = cctable[value:lower()] end
    if arg == 'icon' then state = cctable[value:lower()] end
    if arg == 'cc' then state = cctable[value:lower()] end
    
    if arg == 'img' then filepath = value end
    
    if arg == 'level' then unit_level = value end
    if arg == 'lvl' then unit_level = value end
    if arg == 'lv' then unit_level = value end
    
    if arg == 'title' then title = value end
    
    if arg == 'skill'
    then 
        skill_level = value
        local temp = value:lower()
        if temp == 'awakened' or temp == 'saw'
        then
            isSaw = true
        end
    end
    
    if arg == 'cost' then cost_reduction = value end
    if arg == 'cr' then cost_reduction = value end
    
    if arg == 'note' then note = value end
    
    if arg == 'nickname' then nickname = value end
    
    if arg == 'aff' then affection = value.."%" else affection = "" end
  
  end
  
  unit_level = unit_level or 1
  skill_level = skill_level or 1
  cost_reduction = cost_reduction or 0
  
  local isPrince = princeMap[name:lower()]
  if isPrince
  then
      state = princeAW[name:lower()]
      filepath = filepath or (princeMap[name:lower()]..'_Sprite.gif|link=Prince')
      if state ~= '' then state = '[[File:'..state..'Icon.png|24px|link=]]' end
     
      if title ~= ''
      then
          season = title
      else
          season = name:match('[^%(%)]+%(([^%(%)]+)%)')
          if season then 
            scolor = 'black'
          else
            season = ''
          end
      end
      
      name = 'Prince'
  else
      if state ~= '' then state = state..' 'end
      filepath = filepath or (name..' '..state..'_Sprite.gif')
      filepath = (filepath..'|link='..name)
      if state:match('AW2v') then state = 'AW2 ' end
      if state ~= '' then 
          if isSaw
          then state = '[[File:'..state..'Icon.png|24px|link=]]'
          else state = '[[File:'..state..'Icon.png|24px|link=]]'
          end
        end
      
      if title ~= ''
      then
          season = title
      else
          season = name:match('[^%(%)]+%(([^%(%)]+)%)')
          if season then 
            scolor = colors[season:lower()]
            season = season..' Ver.'
          else
            season = ''
          end
          
          event = name:match('[^%(%)]+%【([^%(%)]+)%】')
          if event
          then
              scolor = 'black'
              season = event
          end
      end
      
      name = name:match('([^%(%)]+)')
  end
  if not scolor then scolor = 'black' end
  if nickname then name = nickname end
  if #name>17 then 
      bigname = ' unitcards-title-tiny'
  elseif #name>15 then 
      bigname = ' unitcards-title-small'
  else 
      bigname = '' 
  end
      
  out = ''
  out = out ..'<div class="unitcards-main">'
  out = out ..  '<div style="height:0px;">'
  out = out ..    '<div style="height:6px;"></div>'
  out = out ..    '<div style="margin-left:91px;height:26px;width:24px;">'..state..'</div>'  
  
  out = out ..    '<div class="unitcards-seasonal" style="color:'..scolor..';">'..season..'</div>'
  out = out ..  '</div>'
  out = out ..  '<div>'
  out = out ..    '<div class="unitcards-title'..bigname..'">'
  out = out ..      '<span>'..name..'</span>'
  out = out ..    '</div>'
  out = out ..    '<div class="unitcards-icon">[[File:'..filepath..']]</div>'
  out = out ..    '<div class="unitcards-info">'
  out = out ..      '<div class="unitcards-entry">'
  out = out ..        '<span class="unitcards-label">Level:</span>'
  out = out ..        '<span class="unitcards-labeled_data">'..unit_level..'</span>'
  out = out ..      '</div>'
  out = out ..      '<div class="unitcards-entry">'
  out = out ..        '<span class="unitcards-label">Skill:</span>'
  if isSaw
  then
    out = out .. '<span style="display:block;margin-left:90px;position:relative;top:-6px;height:7px;width:6px;">'..sawIcon..'</span>'
    out = out ..        '<span class="unitcards-labeled_data"> </span>'
  else
    out = out ..        '<span class="unitcards-labeled_data">'..skill_level..'</span>'
  end
  out = out ..      '</div>'
  out = out ..      '<div class="unitcards-entry">'
  out = out ..        '<span class="unitcards-label">Affection:</span>'
  out = out ..        '<span class="unitcards-labeled_data">'..affection..'</span>'
  out = out ..      '</div>'
  out = out ..      '<div class="unitcards-entry">'
  out = out ..        '<span class="unitcards-label">CR:</span>'
  out = out ..        '<span class="unitcards-labeled_data">'..cost_reduction..'</span>'
  out = out ..      '</div>'
  out = out ..      '<div class="unitcards-entry">'
  out = out ..        '<span class="unitcards-label"></span>'
  out = out ..        '<span class="unitcards-labeled_data">'..note..'</span>'
  out = out ..      '</div>'
  out = out ..    '</div>'
  out = out ..  '</div>'
  out = out ..'</div>'
  return out
end
return shiny