FANDOM


local p = {}
local html = {}
 
function p.decks(frame)
    local sortcardnames = {} -- cartas ordenadas
    local allcardnames = {} -- valores ingresados
    local cardnames = {}
 
    -- contadores de cartas para cada deck
    local main_n = 0 -- contador maindeck
    local extra_n = 0
    local side_n = 0
 
    -- almacenan los id de las cartas (normalizados)
    local maindeck = {}
    local extradeck = {}
    local sidedeck = {}
 
 
    local edeck = {}
    local edeck_n = 0
 
    local text = ''
 
    for name, value in pairs(frame.args) do
        if value ~= '' then
            local cardname = p.normalize(value) -- id (nombre normalizado)
            local index = string.lower(name) -- normaliza índice
            local letter = string.sub(index, 0, 1) -- extrae primera letra
            if letter == 'd' then
                maindeck[index] = {}
                maindeck[index]['id'] = cardname
                maindeck[index]['notfound'] = value
                main_n = main_n + 1 -- contador
                else if letter == 'e' then
                    extradeck[index] = {}
                    extradeck[index]['id'] = cardname
                    extradeck[index]['notfound'] = value
                    extra_n = extra_n + 1 -- contador
                    else if letter == 's' then
                        sidedeck[index] = {}
                        sidedeck[index]['id'] = cardname
                        sidedeck[index]['notfound'] = value
                        side_n = side_n + 1 --contador
                    end
                end
            end
 
            if cardnames[cardname] == nil then
                cardnames[cardname] = {}
                table.insert(sortcardnames, cardname)
            end
            table.insert(allcardnames, value)
        end
    end
 
    table.sort(sortcardnames)
    table.sort(allcardnames)
    cardnames = p.getCardsData(sortcardnames)
 
    text = html.deck(main_n, maindeck, extra_n, extradeck, side_n, sidedeck, cardnames, allcardnames)
 
    return text
end
 
function p.getCardsData(sortcardnames)
    local temp = {}
    local RdDatos = {}
    local RdRestriccion = require('Módulo:RestriccionCarta')
    local RdLetter = ''
 
    for i, n in ipairs(sortcardnames) do
        local Letter = p.selectLetter(string.sub(n, 0, 1))
        if RdLetter ~= Letter then
            RdLetter = Letter
            RdDatos = require('Módulo:RdDatos' .. RdLetter)
        end
 
        temp[n] = {}
        if RdDatos[n] ~= nil then
            local rddatos = RdDatos[n]
            temp[n]['nombre'] = rddatos[1]
            temp[n]['ingles'] = rddatos[2]
            temp[n]['carta'] = rddatos[3]
            temp[n]['atributo'] = rddatos[4]
            temp[n]['tipo'] = rddatos[5]
            if rddatos[4] ~= 'mágica' and rddatos[4] ~= 'trampa' then
                if rddatos[3] ~= 'monstruo de enlace' then
                    temp[n]['nivel'] = rddatos[6]
                    temp[n]['ataque'] = rddatos[7]
                    temp[n]['defensa'] = rddatos[8]
                    temp[n]['codigo'] = rddatos[9]
                else
                    temp[n]['ataque'] = rddatos[6]
                    temp[n]['codigo'] = rddatos[7]
                end
            else
                temp[n]['codigo'] = rddatos[6]
            end
 
            -- Los índices de restricción solo están en español (rddatos[1])
            local restriccion = RdRestriccion[p.normalize(rddatos[1])]
            if restriccion ~= nil then
                local str_restriccion = {'ocg', 'prohibida', 'limitada', 'semilimitada'}
                temp[n]['restriccion'] = str_restriccion[restriccion]
            end
        end
    end
 
    return temp
end
 
function p.selectLetter(letter)    
    local char_n = string.byte(letter)
    if char_n > 64 and char_n < 91 then
        return letter
    else
        return '7'
    end
end
 
function p.normalize (cardname)
    cardname = string.lower(cardname)
    cardname = string.gsub(cardname, 'Á', 'a')
    cardname = string.gsub(cardname, 'Ä', 'a')
    cardname = string.gsub(cardname, 'Â', 'a')
    cardname = string.gsub(cardname, 'É', 'e')
    cardname = string.gsub(cardname, 'Ë', 'e')
    cardname = string.gsub(cardname, 'Í', 'i')
    cardname = string.gsub(cardname, 'Ï', 'i')
    cardname = string.gsub(cardname, 'Ó', 'o')
    cardname = string.gsub(cardname, 'Ö', 'o')
    cardname = string.gsub(cardname, 'Ú', 'u')
    cardname = string.gsub(cardname, 'Ü', 'u')
 
    cardname = string.gsub(cardname, 'á', 'a')
    cardname = string.gsub(cardname, 'ä', 'a')
    cardname = string.gsub(cardname, 'â', 'a')
    cardname = string.gsub(cardname, 'é', 'e')
    cardname = string.gsub(cardname, 'ë', 'e')
    cardname = string.gsub(cardname, 'í', 'i')
    cardname = string.gsub(cardname, 'ï', 'i')
    cardname = string.gsub(cardname, 'ó', 'o')
    cardname = string.gsub(cardname, 'ö', 'o')
    cardname = string.gsub(cardname, 'ú', 'u')
    cardname = string.gsub(cardname, 'ü', 'u')
 
    cardname = string.upper(cardname)
    cardname = string.gsub(cardname, ' ', '')
    cardname = string.gsub(cardname, '"', '')
    cardname = string.gsub(cardname, "'", '')
    cardname = string.gsub(cardname, ',', '')
    cardname = string.gsub(cardname, '%.', '')
    cardname = string.gsub(cardname, '%-', '')
    cardname = string.gsub(cardname, '¡', '')
    cardname = string.gsub(cardname, '!', '')
    cardname = string.gsub(cardname, '¿', '')
    cardname = string.gsub(cardname, '%?', '')
    cardname = string.gsub(cardname, ':', '')
    cardname = string.gsub(cardname, 'º', '')
    cardname = string.gsub(cardname, '/', '')
    cardname = string.gsub(cardname, '#', '')
    cardname = string.gsub(cardname, '&', 'Y')
 
    cardname = string.gsub(cardname, '“', '')
    cardname = string.gsub(cardname, '”', '')
    cardname = string.gsub(cardname, '’', '')
    cardname = string.gsub(cardname, '%–', '')
    cardname = string.gsub(cardname, 'ñ', 'Ñ')
    cardname = string.gsub(cardname, '·', '')
    cardname = string.gsub(cardname, '☆', '')
    cardname = string.gsub(cardname, 'ß', 'B')
    return cardname
end
 
function p.convnombreimagen(filename)
    filename = string.lower(filename)
    filename = string.gsub(filename, 'Á', 'á')
    filename = string.gsub(filename, 'Ä', 'ä')
    filename = string.gsub(filename, 'Â', 'â')
    filename = string.gsub(filename, 'É', 'é')
    filename = string.gsub(filename, 'Ë', 'ë')
    filename = string.gsub(filename, 'Í', 'í')
    filename = string.gsub(filename, 'Ï', 'ï')
    filename = string.gsub(filename, 'Ó', 'ó')
    filename = string.gsub(filename, 'Ö', 'ö')
    filename = string.gsub(filename, 'Ú', 'ú')
    filename = string.gsub(filename, 'Ü', 'ü')
 
    filename = string.gsub(filename, '/', '-')
    filename = string.gsub(filename, '&#39;', '')
    filename = string.gsub(filename, '\'', '')
    filename = string.gsub(filename, '"', '')
    filename = string.gsub(filename, '&quot;', '')
    filename = string.gsub(filename, '&#34;', '')
    filename = string.gsub(filename, '?', '')
    filename = string.gsub(filename, '&#3f;', '')
 
    return filename
end
 
function html.deck (main_n, maindeck, extra_n, extradeck, side_n, sidedeck, cardnames, allcardnames)
    local text = ''
 
    -- Tab: Vista Principal
    text = text .. 'Vista Principal =\n'    
 
    -- Deck Principal
	text = text .. '<div class="hidden">\n'
    text = text .. '<div class="deck_header">\'\'\'DECK PRINCIPAL\'\'\'<div style="float:right; margin-right:8px">\'\'\'' .. main_n .. '\'\'\'</div></div>'
    text = text .. '<div style="background-color:#E98B14; background: linear-gradient(to bottom, #de6f03 0%,#e98911 50%,#eab97f 100%); height: 1%; overflow: hidden;">'
 
    if maindeck['d1'] ~= nil then
        local i = 1
        while maindeck['d' .. i] ~= nil do
            local maincard = maindeck['d' .. i]
            local cardname = cardnames[maincard.id]
            text = text .. '<div class="carta_thumb">'
            text = text .. html.cardview(cardname, maincard.notfound)
            text = text .. '<div class="num_tag">D' .. i .. '</div></div>'
            i = i + 1
        end
    else
        text = text .. '<div style="text-align:center">-- Sin cartas --</div>\n'
    end
 
    text = text .. '</div>\n'
 
    -- Deck Extra
    text = text .. '<div class="deck_header">\'\'\'DECK EXTRA\'\'\'<div style="float:right; margin-right:8px">\'\'\'' .. extra_n .. '\'\'\'</div></div>'
    text = text .. '<div style="background-color:#0099D2; background: linear-gradient(to bottom, #0292C7 0%,#0099D2 50%,#74C3E2 100%); height: 1%; overflow: hidden;">'
 
    if extradeck['e1'] ~= nil then
        local i = 1
        while extradeck['e' .. i] ~= nil do
            local extracard = extradeck['e' .. i]
            local cardname = cardnames[extracard.id]
            text = text .. '<div class="carta_thumb">'
            text = text .. html.cardview(cardname, extracard.notfound)
            text = text .. '<div class="num_tag">E' .. i .. '</div></div>'
            i = i + 1
        end
    else
        text = text .. '<div style="text-align:center">-- Sin cartas --</div>\n'
    end
 
    text = text .. '</div>\n'
 
    -- Side Deck
    text = text .. '<div class="deck_header">\'\'\'SIDE DECK\'\'\'<div style="float:right; margin-right:8px">\'\'\'' .. side_n .. '\'\'\'</div></div>'
    text = text .. '<div style="background-color:#8DB71B; background: linear-gradient(to bottom, #72AA01 0%,#92B920 50%,#B8CF75 100%); height: 1%; overflow: hidden;">'
 
    if sidedeck['s1'] ~= nil then
        local i = 1
        while sidedeck['s' .. i] ~= nil do
            local sidecard = sidedeck['s' .. i]
            local cardname = cardnames[sidecard.id]
            text = text .. '<div class="carta_thumb">'
            text = text .. html.cardview(cardname, sidecard.notfound)
            text = text .. '<div class="num_tag">S' .. i .. '</div></div>'
            i = i + 1
        end
    else
        text = text .. '<div style="text-align:center">-- Sin cartas --</div>\n'
    end
 
    text = text .. '</div>\n'
    text = text .. '{{Plantilla:RecetaDeckLUA/info}}\n'
	text = text .. '</div>\n'
 
    -- Lista de cartas
    text = text .. '|-|\n'
    text = text .. 'Lista de cartas=\n'
    text = text .. '<div class="decklist_sections">\n'
 
	-- Lista de cartas: Deck Principal
 
	local d_monstruos = ''
	local d_magicas = ''
	local d_trampas = ''
	local d_desconocidas = ''
 
	local count_deck = 0
	local count_magicas = 0
	local count_trampas = 0
	local count_monstruos = 0
	local count_ddesconocidas = 0
 
	if maindeck['d1'] ~= nil then
        local i = 1
		local lastcard = nil
		local lastnotfound = nil
		local lastcount = 1
		local maincard = nil
 
        while maindeck['d' .. i] ~= nil do
            maincard = maindeck['d' .. i]
 
			if maincard.id ~= lastcard then
			    if lastcard ~= nil then
			        local cardname = cardnames[lastcard]
				    -- text = text .. html.cardline(cardname, lastnotfound, lastcount)
				    if cardname.atributo == 'mágica' then
				        d_magicas = d_magicas .. html.cardline(cardname, lastnotfound, lastcount)
				        count_magicas = count_magicas + lastcount
			        else
			            if cardname.atributo == 'trampa' then
    			            d_trampas = d_trampas .. html.cardline(cardname, lastnotfound, lastcount)
    			            count_trampas = count_trampas + lastcount
    			        else
    			            if cardname.nombre ~= nil then
    			                d_monstruos = d_monstruos .. html.cardline(cardname, lastnotfound, lastcount)
    			                count_monstruos = count_monstruos + lastcount
    			            else
    			                d_desconocidas = d_desconocidas .. html.cardline(cardname, lastnotfound, lastcount)
    			                count_ddesconocidas = count_ddesconocidas + lastcount
    			            end
    			        end
				    end
				end
				lastcard = maincard.id
				lastnotfound = maincard.notfound
				lastcount = 1
			else
			    lastcount = lastcount + 1
			end
 
            i = i + 1
        end
 
		local cardname = cardnames[lastcard]
		-- text = text .. html.cardline(cardname, lastnotfound, lastcount)
	    if cardname.atributo == 'mágica' then
	        d_magicas = d_magicas .. html.cardline(cardname, lastnotfound, lastcount)
	        count_magicas = count_magicas + lastcount
        else
            if cardname.atributo == 'trampa' then
	            d_trampas = d_trampas .. html.cardline(cardname, lastnotfound, lastcount)
	            count_trampas = count_trampas + lastcount
	        else
	            if cardname.nombre ~= nil then
	                d_monstruos = d_monstruos .. html.cardline(cardname, lastnotfound, lastcount)
	                count_monstruos = count_monstruos + lastcount
	            else
	                d_desconocidas = d_desconocidas .. html.cardline(cardname, lastnotfound, lastcount)
	                count_ddesconocidas = count_ddesconocidas + lascount
	            end
	        end
        end
 
        count_deck = count_monstruos + count_magicas + count_trampas + count_ddesconocidas
        text = text .. '<h3>Deck Principal (' .. count_deck .. ')</h3>\n'
    	text = text .. '<ul>'
 
        if d_desconocidas ~= '' then
            d_desconocidas = '<h4>Cartas desconocidas (' .. count_ddesconocidas .. ')</h4>\n' .. d_desconocidas
            text = text .. d_desconocidas
        end
 
        if d_monstruos ~= '' then
            d_monstruos = '<h4>Monstruos (' .. count_monstruos .. ')</h4>\n' .. d_monstruos
            text = text .. d_monstruos
        end
 
        if d_magicas ~= '' then
            d_magicas = '<h4>Mágicas (' .. count_magicas .. ')</h4>\n' .. d_magicas
            text = text .. d_magicas
        end
 
        if d_trampas ~= '' then
            d_trampas = '<h4>Trampas (' .. count_trampas .. ')</h4>\n' .. d_trampas
            text = text .. d_trampas
        end
 
	else
	    text = text .. '<h3>Deck Principal</h3>\n'
    	text = text .. '<ul>'
	    text = text .. '<li>\'\'-- Sin cartas --\'\'</li>'
    end
	text = text .. '</ul>'
 
	-- Lista de cartas: Deck Extra
	local e_fusiones = ''
	local e_sincronias = ''
	local e_xyz = ''
	local e_enlaces = ''
	local e_desconocidas = ''
 
	local count_extra = 0
	local count_fusiones = 0
	local count_sincronias = 0
	local count_xyz = 0
	local count_enlaces = 0
	local count_edesconocidas = 0
 
	if extradeck['e1'] ~= nil then		
        local i = 1
		local lastcard = nil
		local lastnotfound = nil
		local lastcount = 1
		local maincard = nil
 
        while extradeck['e' .. i] ~= nil do
            maincard = extradeck['e' .. i]
 
			if maincard.id ~= lastcard then
			    if lastcard ~= nil then
			        local cardname = cardnames[lastcard]
				    if cardname.carta == 'monstruo de fusión' or cardname.carta == 'monstruo de fusión cantante' or cardname.carta == 'monstruo péndulo de fusión' then
            	        e_fusiones = e_fusiones .. html.cardline(cardname, lastnotfound, lastcount)
            	        count_fusiones = count_fusiones + lastcount
                    else
                        if cardname.carta == 'monstruo de sincronía' or cardname.carta == 'monstruo de sincronía cantante' or cardname.carta == 'monstruo péndulo de sincronía' then
            	            e_sincronias = e_sincronias .. html.cardline(cardname, lastnotfound, lastcount)
            	            count_sincronias = count_sincronias + lastcount
            	        else
            	            if cardname.carta == 'monstruo xyz' or cardname.carta == 'monstruo péndulo xyz' then
                	            e_xyz = e_xyz .. html.cardline(cardname, lastnotfound, lastcount)
                	            count_xyz = count_xyz + lastcount
                	        else
                	            if cardname.carta == 'monstruo de enlace' then
            	                    e_enlaces = e_enlaces .. html.cardline(cardname, lastnotfound, lastcount)
            	                    count_enlaces = count_enlaces + lastcount
            	                else
            	                    e_desconocidas = e_desconocidas .. html.cardline(cardname, lastnotfound, lastcount)
            	                    count_edesconocidas = count_edesconocidas + lastcount
            	                end
            	            end
            	        end
                    end
				end
				lastcard = maincard.id
				lastnotfound = maincard.notfound
				lastcount = 1
			else
			    lastcount = lastcount + 1
			end
 
            i = i + 1
        end
 
		local cardname = cardnames[lastcard]
		if cardname.carta == 'monstruo de fusión' or cardname.carta == 'monstruo de fusión cantante' or cardname.carta == 'monstruo péndulo de fusión' then
	        e_fusiones = e_fusiones .. html.cardline(cardname, lastnotfound, lastcount)
	        count_fusiones = count_fusiones + lastcount
        else
            if cardname.carta == 'monstruo de sincronía' or cardname.carta == 'monstruo de sincronía cantante' or cardname.carta == 'monstruo péndulo de sincronía' then
	            e_sincronias = e_sincronias .. html.cardline(cardname, lastnotfound, lastcount)
	            count_sincronias = count_sincronias + lastcount
	        else
	            if cardname.carta == 'monstruo xyz' or cardname.carta == 'monstruo péndulo xyz' then
    	            e_xyz = e_xyz .. html.cardline(cardname, lastnotfound, lastcount)
    	            count_xyz = count_xyz + lastcount
    	        else
    	            if cardname.carta == 'monstruo de enlace' then
	                    e_enlaces = e_enlaces .. html.cardline(cardname, lastnotfound, lastcount)
	                    count_enlaces = count_enlaces + lastcount
	                else
	                    e_desconocidas = e_desconocidas .. html.cardline(cardname, lastnotfound, lastcount)
	                    count_edesconocidas = count_edesconocidas + lastcount
	                end
	            end
	        end
        end
 
    	count_extra = count_fusiones + count_sincronias + count_xyz + count_enlaces + count_edesconocidas
    	text = text .. '<h3>Deck Extra (' .. count_extra .. ')</h3>\n'
    	text = text .. '<ul>'
 
        if e_desconocidas ~= '' then
            e_desconocidas = '<h4>Cartas desconocidas (' .. count_edesconocidas .. ')</h4>\n' .. e_desconocidas
            text = text .. e_desconocidas
        end
 
        if e_fusiones ~= '' then
            e_fusiones = '<h4>Fusiones (' .. count_fusiones .. ')</h4>\n' .. e_fusiones
            text = text .. e_fusiones
        end
 
        if e_sincronias ~= '' then
            e_sincronias = '<h4>Sincronías (' .. count_sincronias .. ')</h4>\n' .. e_sincronias
            text = text .. e_sincronias
        end
 
        if e_xyz ~= '' then
            e_xyz = '<h4>Xyz (' .. count_xyz .. ')</h4>\n' .. e_xyz
            text = text .. e_xyz
        end
 
        if e_enlaces ~= '' then
            e_enlaces = '<h4>Enlaces (' .. count_enlaces .. ')</h4>\n' .. e_enlaces
            text = text .. e_enlaces
        end
	else
	    text = text .. '<h3>Deck Extra</h3>\n'
    	text = text .. '<ul>'
	    text = text .. '<li>\'\'-- Sin cartas --\'\'</li>'
    end
	text = text .. '</ul>'
 
	-- Lista de cartas: Side Deck
	text = text .. '<h3>Side Deck</h3>\n'
	text = text .. '<ul>'
 
	if sidedeck['s1'] ~= nil then		
        local i = 1
		local lastcard = nil
		local lastnotfound = nil
		local lastcount = 1
		local maincard = nil
 
        while sidedeck['s' .. i] ~= nil do
            maincard = sidedeck['s' .. i]
 
			if maincard.id ~= lastcard then
			    if lastcard ~= nil then
			        local cardname = cardnames[lastcard]
				    text = text .. html.cardline(cardname, lastnotfound, lastcount)
				end
				lastcard = maincard.id
				lastnotfound = maincard.notfound
				lastcount = 1
			else
			    lastcount = lastcount + 1
			end
 
            i = i + 1
        end
 
		local cardname = cardnames[lastcard]
		text = text .. html.cardline(cardname, lastnotfound, lastcount)
	else
	    text = text .. '<li>\'\'-- Sin cartas --\'\'</li>'
    end
	text = text .. '</ul>\n'
	text = text .. '</div>\n'
 
	-- YGOPro
    text = text .. '|-|\n'
    text = text .. 'YGOPro (ydk)=\n'
    text = text .. '<div class="hidden">'
    text = text .. '[[image:Ygopro.png]]<br>\n'
    text = text .. '<p>Esta receta se visualiza en formato compatible con YGOPRO. Puedes hacer click en el botón "Descargar el deck", o puedes copiar el texto en un editor y guardarlo con la extensión ".ydk" para cargarlo en el juego.</p>\n'
 
    local text2 = '<pre id="data-ydk">\n'
    text2 = text2 .. '#created by ...\n'
 
	-- YGOPro: Deck Principal
	text2 = text2 .. '#main\n'
 
	if maindeck['d1'] ~= nil then
	    local i = 1
		local maincard = nil
 
        while maindeck['d' .. i] ~= nil do
            maincard = maindeck['d' .. i]
            local cardname = cardnames[maincard.id]
            if cardname.codigo ~= nil then
                text2 = text2 .. cardname.codigo .. '\n'
            end
            i = i + 1
        end
    end
 
	-- YGOPro: Deck Extra
	text2 = text2 .. '#extra\n'
 
	if extradeck['e1'] ~= nil then
	    local i = 1
		local maincard = nil
 
        while extradeck['e' .. i] ~= nil do
            maincard = extradeck['e' .. i]
            local cardname = cardnames[maincard.id]
            if cardname.codigo ~= nil then
                text2 = text2 .. cardname.codigo .. '\n'
            end
 
            i = i + 1
        end
    end
 
	-- YGOPro: Side Deck
	text2 = text2 .. '!side\n'
 
	if sidedeck['s1'] ~= nil then
	    local i = 1
		local maincard = nil
 
        while sidedeck['s' .. i] ~= nil do
            maincard = sidedeck['s' .. i]
            local cardname = cardnames[maincard.id]
            if cardname.codigo ~= nil then
                text2 = text2 .. cardname.codigo .. '\n'
            end
 
            i = i + 1
        end
    end
 
    text2 = text2 .. '</pre>\n'
 
    local text3 = ''
 
    local lastcard = nil
    local lastcardname = nil
    local lastcount = 0
 
    for i, n in ipairs(allcardnames) do
        local name = p.normalize(n)
 
        if lastcard ~= name then
            if lastcard ~= nil then
                local cardname = cardnames[lastcard]
                if cardname.nombre ~= nil then
                    if cardname.codigo == nil then
                        text3 = text3 .. '<li>[[image:clase retirar carta.gif|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' no posee código aún y fue excluida de la lista.</li>'
                    elseif cardname.restriccion == 'prohibida' then
                        text3 = text3 .. '<li>[[image:nuevo icono restricción prohibida.png|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' se encuentra prohibida.</li>'
                    elseif lastcount > 3 then
                        text3 = text3 .. '<li>[[image:nuevo icono restricción prohibida.png|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' excede el número de copias para un deck.</li>'
                    elseif lastcount > 2 and cardname.restriccion == 'semilimitada' then
                        text3 = text3 .. '<li>[[image:nuevo icono restricción semilimitada.png|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' está semi-limitada y excede el número de copias.</li>'
                    elseif lastcount > 1 and cardname.restriccion == 'limitada' then
                        text3 = text3 .. '<li>[[image:nuevo icono restricción limitada.png|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' está limitada y excede el número de copias.</li>'
                    end
                else
                    text3 = text3 .. '<li>[[image:clase retirar carta.gif|sub]] La carta \'\'\'\'\'' .. lastcardname .. '\'\'\'\'\' no está registrada y fue excluida de la lista.</li>'
                end
            end
            lastcard = name
            lastcardname = n
            lastcount = 1
        else
            lastcount = lastcount + 1
        end
 
    end
 
    -- Ultima carta
    local cardname = cardnames[lastcard]
    if cardname.nombre ~= nil then
        if cardname.codigo == nil then
            text3 = text3 .. '<li>[[image:clase retirar carta.gif|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' no posee código aún.</li>'
        elseif cardname.restriccion == 'prohibida' then
            text3 = text3 .. '<li>[[image:nuevo icono restricción prohibida.png|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' se encuentra prohibida.</li>'
        elseif lastcount > 3 then
            text3 = text3 .. '<li>[[image:nuevo icono restricción prohibida.png|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' excede el número de copias para un deck.</li>'
        elseif lastcount > 2 and cardname.restriccion == 'semilimitada' then
            text3 = text3 .. '<li>[[image:nuevo icono restricción semilimitada.png|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' está semi-limitada y excede el número de copias.</li>'
        elseif lastcount > 1 and cardname.restriccion == 'limitada' then
            text3 = text3 .. '<li>[[image:nuevo icono restricción limitada.png|sub]] La carta \'\'\'' .. cardname.nombre .. '\'\'\' está limitada y excede el número de copias.</li>'
        end
    else
        text3 = text3 .. '<li>[[image:clase retirar carta.gif|sub]] La carta \'\'\'' .. lastcardname .. '\'\'\' no se encuentra registrada</li>'
    end
 
    if text3 ~= '' then
        text = text .. '<p>\'\'\'ATENCION:\'\'\' Se han detectado los siguientes problemas: </p>\n<ul>\n' .. text3 .. '</ul>\n'
    else
        text = text .. '<p>No se han detectado problemas. Todas las cartas se encuentran registradas correctamente.</p>\n'
    end
 
    text = text .. '<p><div id="download-ydk"></div></p>\n'
 
    text = text .. text2
    text = text .. '</div>'
 
    return text
end
 
function html.cardview (cardname, notfound)
 
    local text = ''
 
    if cardname.carta ~= nil then
        local tmb_image = 'Thumb3 ' .. string.lower(cardname.carta) .. ' '
        if cardname.atributo == 'mágica' or cardname.atributo == 'trampa' then
            tmb_image = tmb_image ..  cardname.tipo
        else 
            tmb_image = tmb_image ..  cardname.atributo
        end
 
        local tmb_class = 'tmbfoto'
        local tmb_size = '40x40'
 
        if cardname.carta == 'monstruo de enlace' then
            tmb_class = tmb_class .. 'enlace'
            tmb_size = '42x42'
        end
 
        if cardname.carta == 'monstruo péndulo' or cardname.carta == 'monstruo péndulo normal' or cardname.carta == 'monstruo péndulo xyz' or cardname.carta == 'monstruo péndulo cantante' or cardname.carta == 'monstruo péndulo cantante normal' or cardname.carta == 'monstruo péndulo de sincronía' or cardname.carta == 'monstruo péndulo de fusión' then
            tmb_class = tmb_class .. 'pendulum'
            tmb_size = '48x36'
        end
 
        local tmb_filename = p.convnombreimagen(cardname.nombre)
 
        text = text .. '<div class="tmbcarta">[[image:' .. tmb_image .. '.png]]</div><div class="' .. tmb_class .. '">[[image:Foto ' .. tmb_filename .. '.jpg|' .. cardname.nombre .. '|' .. tmb_size .. 'px]]</div>'
 
        -- Restriccion
        if cardname.restriccion ~= nil then
            local restfilename = ''
            if cardname.restriccion == 'ocg' then
                restfilename = 'icono ocg'
            else
                restfilename = 'Nuevo icono restricción ' .. cardname.restriccion
            end
            text = text .. '<div class="tmbrest">[[Archivo:' .. restfilename .. '.png]]</div>'
        end
 
    else
        text = text .. '<div class="tmbdesc">[[image:Thumb3 desconocido.png|' .. notfound .. ']][[Categoría:Thumb desconocido]]</div>'
    end
 
    return text
end
 
function html.cardline (cardname, notfound, counter)
 
	local text = ''
 
	if cardname.nombre ~= nil then
	    text = '<li><div class="decklist_section1"><span class="decklist_section1_1">[[image:icono ' .. string.lower(cardname.carta)
 
	    if counter == 2 then
	        text = text .. ' x2'
	    elseif counter > 2 then
	        text = text .. ' x3'
	    end
 
	    text = text .. '.gif]]\'\'\'x' .. counter .. ' ' .. '</span><span class="decklist_section1_2">[[w:c:es.yugioh:' .. cardname.nombre .. '|' .. cardname.nombre .. ']]\'\'\'</span></div><div class="decklist_section2">\n'
		text = text .. '\'\'(' .. cardname.ingles .. ')\'\'</div><div class="decklist_section3"><span class="decklist_section3_1">\n'
 
		text = text .. '[[image:icono ' .. string.lower(cardname.atributo) .. '.gif]]'
        text = text .. '[[image:icono ' .. string.lower(cardname.tipo) .. '.gif]]'
 
        if cardname.atributo ~= 'mágica' and cardname.atributo ~= 'trampa' and cardname.carta ~= 'monstruo de enlace' then
            if cardname.carta == 'monstruo xyz' then
                text = text .. ' [[image:icono rango.gif]]' .. cardname.nivel
            else
                text = text .. ' [[image:icono nivel.gif]]' .. cardname.nivel
            end 
            text = text .. '</span><span class="decklist_section3_2">'
            text = text .. ' [[image:icono ataque.gif]]' .. cardname.ataque
            if cardname.carta ~= 'monstruo de enlace' then
                text = text .. ' [[image:icono defensa.gif]]' .. cardname.defensa
            end
        end
 
		text = text .. '</span>'
 
		if cardname.restriccion ~= nil then
            local restfilename = ''
            if cardname.restriccion == 'ocg' then
                restfilename = 'icono ocg'
            else
                restfilename = 'Nuevo icono restricción ' .. cardname.restriccion
            end
            text = text .. '</div><div class="decklist_section4">[[image: ' .. restfilename .. '.png]] '
        end
 
		text = text .. '</div></li><br>\n'
	else
	    text = '<li><div>[[image:icono monstruo normal.gif]]\'\'\'x' .. counter .. ' \'\'' .. notfound .. '\'\'\'<br>\n(carta no registrada)\'\'</div></li><br>\n'
	end
 
	return text
end
 
return p

¡Interferencia de bloqueo de anuncios detectada!


Wikia es un sitio libre de uso que hace dinero de la publicidad. Contamos con una experiencia modificada para los visitantes que utilizan el bloqueo de anuncios

Wikia no es accesible si se han hecho aún más modificaciones. Si se quita el bloqueador de anuncios personalizado, la página cargará como se esperaba.