FANDOM


local p = {}
local html = {}
 
function p.decks(frame)
    local sortcardnames = {}
    local allcardnames = {}
    local cardnames = {}
    local main_n = 0
    local maindeck = {}
    local extra_n = 0
    local extradeck = {}
    local side_n = 0
    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)
            local index = string.lower(name)
            local letter = string.sub(index, 0, 1)
            if letter == 'd' then
                maindeck[index] = {}
                maindeck[index]['id'] = cardname
                maindeck[index]['notfound'] = value
                main_n = main_n + 1
                else if letter == 'e' then
                    extradeck[index] = {}
                    extradeck[index]['id'] = cardname
                    extradeck[index]['notfound'] = value
                    extra_n = extra_n + 1
                    else if letter == 's' then
                        sidedeck[index] = {}
                        sidedeck[index]['id'] = cardname
                        sidedeck[index]['notfound'] = value
                        side_n = side_n + 1
                    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
                temp[n]['nivel'] = rddatos[6]
                temp[n]['ataque'] = rddatos[7]
                temp[n]['defensa'] = rddatos[8]
                temp[n]['codigo'] = rddatos[9]
            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, 'ß', '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">\n'
 
	-- Lista de cartas: Deck Principal	
	text = text .. '<h3>Deck Principal</h3>\n'
	text = text .. '<ul>'
 
	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)
				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>'
 
	-- Lista de cartas: Deck Extra
	text = text .. '<h3>Deck Extra</h3>\n'
	text = text .. '<ul>'
 
	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]
				    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>'
 
	-- 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 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 de sincronía' 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>[[image:icono ' .. string.lower(cardname.carta)
 
	    if counter > 1 then
	        text = text .. ' x' .. counter
	    end
 
	    text = text .. '.gif]]\'\'\'x' .. counter .. ' ' .. '[[w:c:es.yugioh:' .. cardname.nombre .. '|' .. cardname.nombre .. ']]\'\'\'<br>\n'
		text = text .. '\'\'(' .. cardname.ingles .. ')\'\'<br>\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' 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 .. ' [[image:icono ataque.gif]]' .. cardname.ataque
            text = text .. ' [[image:icono defensa.gif]]' .. cardname.defensa
        end
 
		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 .. ' [[image: ' .. restfilename .. '.png]] '
        end
 
		text = text .. '</li><br>\n'
	else
	    text = '<li>[[image:icono monstruo normal.gif]]\'\'\'x' .. counter .. ' \'\'' .. notfound .. '\'\'\'<br>\n(carta no registrada)\'\'</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.

También en FANDOM

Wiki al azar