FANDOM


local p = {}

local skill = require("Module:skill")

local card_data = mw.loadData('Module:card.data')
local card_name = mw.loadData('Module:card.name')
 
local skill_data = mw.loadData('Module:skill.data')
local skill_name = mw.loadData('Module:skill.name')
 
local card_msg_jp = mw.loadData('Module:card.msg.jp')
local card_msg_zht = mw.loadData('Module:card.msg.zht')
 
local card_fusion = mw.loadData('Module:card.fusion')
local card_arcwitch = mw.loadData('Module:card.arcwitch')
local card_awaken = mw.loadData('Module:card.awaken')
local card_treasure = mw.loadData('Module:card.treasure')
 
local card_rare = {'N', 'R', 'SR', 'HN', 'HR', 'HSR', 'N', 'UR', 'HUR', 'GSR', 'GUR', 'LR', 'HLR', 'GLR'}
local card_type1 = {'1', '1', '1', '1', '1', '1', '1', '2', '2', '3', '3', '3', '3', '3'}
local card_type2 = {'2', '1', '3', '4', '5'}

function cat_link(m, t)
    if m then
        if t == nil or t == '' then return '[[Category:' .. m .. ']]'
        else return '[[:Category:' .. m .. '|' .. t ..']]'
        end
    else
        return ''
    end
end

function p.para_calc(frame)
    return para_calc(frame.args[1], frame.args[2], frame.args[3])
end

function p.detail(frame)
	local cardno = frame.args[1]
	local rank = frame.args[2] or '0'
	local cost = frame.args[3] or '??'
	local output = {}

	output[#output+1] = p.star(frame) .. '='
	output[#output+1] = '<div style="position:relative;">'
	output[#output+1] = '<div style="position:absolute; left:4px; z-index:1000;">[[File:card.png|320px|link=]]</div>'
	output[#output+1] = p.img(frame)
	output[#output+1] = '<div style="position:absolute; top:4px; left:6px; z-index:10;">[[File:Attr_' .. card_type1[card_data[cardno][3]] .. '_' .. card_type2[card_data[cardno][4]] .. '.png|link=]]</div>'
	output[#output+1] = '<div style="position:absolute; top:45px; left:6px; z-index:20;">[[File:Rare_' .. card_rare[card_data[cardno][3]] .. '.png|link=]]</div>'
	output[#output+1] = '<div style="position:absolute; top:372px; left:4px; z-index:30;">[[File:card_cost.png|link=]]</div>'
	output[#output+1] = '<div style="position:absolute; top:400px; left:8px; width:70px; text-align:center; z-index:40; padding: 5px; color: #FFFFFF; font-size: 40px;">' .. card_data[cardno][5] .. '</div></div>'
	output[#output+1] = '<div class="cp-icon" style="float:left; border:1px solid #bcc1c4; position:relative; top:-461px; padding:9px; margin-bottom:-461px; margin-right:-336px;">'
	output[#output+1] = p.icon(frame) .. '</div>'

	output[#output+1] = '<div class="cp-para" style="float:left; border:1px solid #bcc1c4; position:relative; top:-311px; left:336px; padding:5px; margin-bottom:-311px; margin-right:0px; font-size:14px; line-height:22px;">'
	output[#output+1] = '<table width="100%" border="0" cellpadding="1" cellspacing="1" class="article-table">'
	output[#output+1] = '  <tr><td width="80px"></td><th>攻擊力</th><th>防禦力</th><th>士兵數</th></tr>'
	output[#output+1] = '  <tr><th>圖鑑預設值</th><td>' .. card_data[cardno][13] .. '</td><td>' .. card_data[cardno][15] .. '</td><td>' .. card_data[cardno][11] .. '</td></tr>'
	output[#output+1] = '  <tr><th>圖鑑最大值</th><td>' .. card_data[cardno][14] .. '</td><td>' .. card_data[cardno][16] .. '</td><td>' .. card_data[cardno][12] .. '</td></tr>'
--	output[#output+1] = '  <tr><th>完美進化</th><td>' .. para_calc(cardno, 14, card_data[cardno][7]) .. '</td><td>' .. para_calc(cardno, 16, card_data[cardno][7]) .. '</td><td>' .. para_calc(cardno, 12, card_data[cardno][7]) .. '</td></tr>'
--	output[#output+1] = '  <tr><th>完美進化</th><td>to ask</td><td>Elit3Blaze</td><td>' .. para_calc(cardno, 12, card_data[cardno][7]) .. '</td></tr>'
	math.randomseed(os.time())
	local r = {math.random(50), math.random(60), math.random(70)}
	if string.sub(cardno,-1) == '0' then r = {[1]=0,[2]=0,[3]=0} end
	output[#output+1] = '  <tr><th>完美進化</th><td>' .. para_calc(cardno, 14, card_data[cardno][7])-r[1] .. '</td><td>' .. para_calc(cardno, 16, card_data[cardno][7])-r[2] .. '</td><td>' .. para_calc(cardno, 12, card_data[cardno][7]) .. '</td></tr>'
	output[#output+1] = '</table></div>'

	-- skill_1
	output[#output+1] = '<div class="cp-s1" style="float:left; border:1px solid #bcc1c4; position:relative; top:-129px; left:336px; padding:5px; margin-bottom:-129px; margin-right:0px; font-size:14px; line-height:22px;">'
	output[#output+1] = '<table width="100%" border="0" cellpadding="1" cellspacing="1" class="article-table">'
	output[#output+1] = '  <tr><th colspan="2" style="text-align:center;">' .. skill_name[card_data[cardno][17]][2] .. '(' .. skill_name[card_data[cardno][17]][1] .. ')' .. '</th></tr>'
--	output[#output+1] = '  <tr><td colspan="2" style="text-align:center;">-- desc --</td></tr>'
	output[#output+1] = '  <tr><th width="40px" height="44px">Lv.1</th><td>' .. skill.skill_1{args={card_data[cardno][17], 0}} .. '</td></tr>'
    output[#output+1] = '  <tr><th height="44px">Lv.10</th><td>' .. skill.skill_1{args={card_data[cardno][17], 1}} .. '</td></tr>'
    output[#output+1] = '</table></div>'
 
    -- skill_2/3/sp
     output[#output+1] = '<div class="cp-s2" style="float:left; border:1px solid #bcc1c4; position:relative; top:2px; left:336px; padding:5px; margin-bottom:2px; margin-right:0px; font-size:14px; line-height:22px;">'
    output[#output+1] = '<table width="100%" border="0" cellpadding="1" cellspacing="1" class="article-table">'
    if card_data[cardno][18] ~= -1 then
        output[#output+1] = '  <tr><th width="73px" height="66px">' .. s_name(skill_name[card_data[cardno][18]][2]) .. '</th><td>' .. skill.skill_2{args={card_data[cardno][18]}} .. '</td></tr>'
    else
        output[#output+1] = '  <tr><th width="60px" height="66px">-</th><td>-</td></tr>'
    end

    if card_data[cardno][19] ~= -1 then
        output[#output+1] = '  <tr><th width="73px" height="66px">' .. s_name(skill_name[card_data[cardno][19]][2]) .. '</th><td>' .. skill.skill_2{args={card_data[cardno][19]}} .. '</td></tr>'
    else
        output[#output+1] = '  <tr><th width="60px" height="66px">-</th><td>-</td></tr>'
    end
 
    if card_data[cardno][20] ~= -1 then
        output[#output+1] = '  <tr><th width="60px" height="44px">覺醒爆發</th><td>' .. skill.skill_sp{args={card_data[cardno][20]}} .. '</td></tr>'
    else
        output[#output+1] = '  <tr><th width="60px" height="44px">-</th><td>-</td></tr>'
    end
        output[#output+1] = '</table></div>'

	-- info
	output[#output+1] = '<div style="float:left; width:328px; border:1px solid #bcc1c4; position:relative; top:-302px; left:-6px; padding:5px; margin-bottom:-201px; margin-right:-0px; font-size:14px; line-height:22px;">'
	output[#output+1] = p.trans(frame)
	if string.sub(cardno, -1) == '2' then output[#output+1] = '來自進化事故:[[file:icon_' .. string.sub(cardno, 1, 4) .. '0.png|48px|link=' .. card_name[string.sub(cardno, 1, 4) .. '0'][2] .. ']]<br/>' end
	if card_fusion[cardno] then output[#output+1] = p.fusion(frame) .. cat_link('可由合成獲得') end
	output[#output+1] = fusion2(cardno)
	if card_treasure[cardno] then output[#output+1] = '聖物獎勵:[[file:Hallow00' .. card_treasure[cardno][1] .. '.png|48px|link=]]' .. card_treasure[cardno][2]  .. '<br/>' .. cat_link('聖物獎勵') end
	if card_arcwitch[cardno] then output[#output+1] = p.arcwitch(frame) end
	if card_awaken[cardno] then output[#output+1] = '可覺醒,基礎成功率:' .. card_awaken[cardno][2] .. '%<br/>' .. cat_link('可覺醒的卡片') end
    --'組隊獎勵:' .. deckbonus(cno)
    output[#output+1] = deckbonus(cardno)
	if skill_data[card_data[cardno][17]][15] == 36 then
    	output[#output+1] = skill.skill_rnd{args={card_data[cardno][17]}}
    end
	output[#output+1] = ' </div>'

	output = {}
	--return table.concat(output)
	return p.star(frame) .. '=[[thread:20818#4|Someone]] say eng. site is easy to use and update quickly, so visit [[w:c:valkyriecrusade|eng. site]], please.<br/>This site don\'t provide card data anymore.<br/>Thanks for your visit longtime.<br/><br/>竟然對小學都沒畢業的人認真了,真是‧‧‧<br/>那就直接讓這裡沒人吧‧‧‧'
end

function p.msg(frame)
    local cardno = frame.args[1]
    local msg_lng = tonumber(frame.args[2]) or 2
    local card_msg = {card_msg_jp, card_msg_zht}
    local output = {}

    if msg_lng ~= 1 and msg_lng~= 2 then msg_lng = 2 end
 
    output[#output+1] = '<div class="cp-desc" style="height:136px; float:left; border:1px solid #bcc1c4; position:absolute; top:-784px; padding:5px; font-size:14px; line-height:22px;">'
    output[#output+1] = '<h1 style="font-size:28px; line-height:28px;">' .. card_name[cardno][msg_lng] .. '</h1><br/>' .. card_msg[msg_lng][1][card_data[cardno][2]]
    output[#output+1] = '</div>'
    output[#output+1] = '<table width="100%" border="0" cellpadding="1" cellspacing="1" class="article-table .cp-msg" style="font-size:14px; line-height:22px;">'
    output[#output+1] = '  <tr><th width="80px">獲得時</th><td>' .. card_msg[msg_lng][2][card_data[cardno][2]] .. '</td></tr>'
    if card_data[cardno][2] <= 1095 then
        if string.len(card_msg[msg_lng][3][card_data[cardno][2]]) > 0 then
                output[#output+1] = '  <tr><th>登入時</th><td>' .. card_msg[msg_lng][3][card_data[cardno][2]] .. '</td></tr>'
        end
    end
    output[#output+1] = '  <tr><th>基本對話</th><td>' .. card_msg[msg_lng][4][card_data[cardno][2]] .. '</td></tr>'
    output[#output+1] = '  <tr><th>滿好感對話</th><td>' .. card_msg[msg_lng][5][card_data[cardno][2]] .. '</td></tr>'
    output[#output+1] = '  <tr><th>戰鬥開始</th><td>' .. card_msg[msg_lng][6][card_data[cardno][2]] .. '</td></tr>'
    output[#output+1] = '  <tr><th>戰鬥落敗</th><td>' .. card_msg[msg_lng][7][card_data[cardno][2]] .. '</td></tr>'
    output[#output+1] = '  <tr><th>親密活動</th><td>' .. card_msg[msg_lng][8][card_data[cardno][2]] .. '</td></tr>'
    output[#output+1] = '</table>'    
 
    --return table.concat(output)
end

function p.mobi(frame)
    local cardno = frame.args[1]
    local cno = cardno
    local ctype = {'光', '火', '水', '暗', '特殊'}
    local output = {}

    output[#output+1] = '[[file:icon_' .. cardno .. '.png|128px|link=]]'
    output[#output+1] = '<h1>' .. card_name[cardno][2] .. '</h1>' .. ctype[card_data[cardno][4]] .. '屬性/' .. card_rare[card_data[cardno][3]] .. '<hr>'
    output[#output+1] = '各階段能力值(完美進化)'
    output[#output+1] = '<table width="100%" border="0" cellpadding="1" cellspacing="1" class="article-table">'
    output[#output+1] = '<tr><td> </td><th>攻擊力</th><th>防禦力</th><th>士兵數</th></tr>'
    output[#output+1] = '<tr><th>' .. p.star(frame) .. '</th><td>' .. para_calc(cardno, 14, card_data[cardno][7]) .. '</td><td>' .. para_calc(cardno, 16, card_data[cardno][7]) .. '</td><td>' .. para_calc(cardno, 12, card_data[cardno][7]) .. '</td></tr>'

    while card_data[cno][8] ~= -1 do
        cno = card_data[cno][8]
        output[#output+1] = '<tr><th>' .. p.star{args={cno}} .. '</th><td>' .. para_calc(cno, 14, card_data[cno][7]) .. '</td><td>' .. para_calc(cno, 16, card_data[cno][7]) .. '</td><td>' .. para_calc(cno, 12, card_data[cno][7]) .. '</td></tr>'
    end

    if card_awaken[cno] then
        cno = card_awaken[cno][1]
        output[#output+1] = '<tr><th>' .. p.star{args={cno}} .. '</th><td>' .. para_calc(cno, 14, card_data[cno][7]) .. '</td><td>' .. para_calc(cno, 16, card_data[cno][7]) .. '</td><td>' .. para_calc(cno, 12, card_data[cno][7]) .. '</td></tr>'
    end

    output[#output+1] = '</table><hr>技能資訊'
    output[#output+1] = '<table width="100%" border="0" cellpadding="1" cellspacing="1" class="article-table">'
    output[#output+1] = '<tr><th>LV.1</th><td>' .. skill.skill_1{args={card_data[cardno][17], 0}} .. '</td></tr>'
    output[#output+1] = '<tr><th>LV.10</th><td>' .. skill.skill_1{args={card_data[cardno][17], 1}} .. '</td></tr>'
    output[#output+1] = '</table><hr>若需詳細資料,請參閱[http://zh.valkyrie-crusade.wikia.com/wiki/' .. cardno .. '?useskin=oasis 桌機版]頁面。'

    output = {'maintenance'}
    return table.concat(output)
end

function p.last_rank(frame)
    local cardno = frame.args[1]
    if cardno == '24200' then
        return 0
    else
        return card_data[cardno][6]
    end
end
 
function p.evo_rank(frame)
    local cardno = frame.args[1]
    if card_data[cardno][3] == 11 and card_data[string.sub(cardno,1,4)..'0'] == nil and card_fusion[cardno] then
        return 1
    else
        return card_data[cardno][7]
    end
end
 
function p.trans(frame)
    local cardno = frame.args[1]
    if card_data[cardno][9] ~= -1 then
        return '進化事故:[[file:icon_' .. card_data[cardno][9] .. '.png|48px|link=' .. card_name[card_data[cardno][9]][2] .. ']]<br/>' .. cat_link('可能發生進化事故')
    else
        return ''
    end
end

-- card img
function p.img(frame)
    local cardno=frame.args[1]
    local rank=frame.args[2] or 0
    local output=''

	if mw.title.new('file:cd_' .. cardno .. '.png').exists then
        output = '[[file:cd_' .. cardno .. '.png|center|320px|link=]]'
    else
        output ='[[file:NoImage.png|center|320px|link=]]'
    end
 
    return output
end
 
-- card icon
function p.icon(frame)
    local cardno=frame.args[1]
    local rank=tonumber(frame.args[2]) or 1
    local output = {}

    if mw.title.new('file:icon_' .. cardno .. '.png').exists then
        output = '[[file:icon_' .. cardno .. '.png|128px|link=]]'
    else
        output = '[[file:icon_00000.png|128px|link=]]'
    end
    return output
end
 
function p.star(frame)
    local cardno = frame.args[1]
    local rank = card_data[cardno][7]
 
    if card_data[cardno][3] == 10 or card_data[cardno][3] == 11 then
        return 'G'
    else
        if rank == 0 then
            return '☆'
        elseif rank == -1 then
            return ' '
        elseif rank >= 1 and rank <= 4 then
            return string.rep('★', rank)
        else
            return '?'
        end
    end
end
 
function p.fusion(frame)
    local cardno = frame.args[1]
    local output = {}
 
    output[#output+1] = '合成:[[file:icon_' .. card_fusion[cardno][1] .. '.png|48px|link='.. card_name[card_fusion[cardno][1]][2] .. ']] × [[file:icon_' .. card_fusion[cardno][2] .. '.png|48px|link='.. card_name[card_fusion[cardno][2]][2] .. ']]'
 
    if string.len(card_fusion[cardno][3]) > 0 then
        output[#output+1] = ' × [[file:icon_' .. card_fusion[cardno][3] .. '.png|48px|link='.. card_name[card_fusion[cardno][3]][2] .. ']]'
    end
    if string.len(card_fusion[cardno][4]) > 0 then
        output[#output+1] = ' × [[file:icon_' .. card_fusion[cardno][4] .. '.png|48px|link='.. card_name[card_fusion[cardno][4]][2] .. ']]'
    end

--    output[#output+1] = ' = [[file:icon_' .. cardno .. '.png|48px|link=]]'
    output[#output+1] = '<br/>'
    return table.concat(output)
end

function fusion2(cno)
    local output = {}

    for key, value in pairs(card_fusion) do
        local i = 1

        repeat
            local tmp
            if value[i] == cno then
                tmp = string.gsub(p.fusion{args={key}},'<br/>','')
                if value[4] ~= '' then tmp = string.gsub(tmp,'合成:','') end
                output[#output+1] = tmp .. ' = ' .. '[[file:icon_' .. key .. '.png|48px|link=' .. card_name[key][2] .. ']]'
            end
            i = i + 1
        until value[i-1] == cno or value[i] == nil
    end

    if #output > 0 then return table.concat(output, '<br/>') .. cat_link('合成素材') .. '<br/>' end
end

 
function p.arcwitch(frame)
    local cardno = frame.args[1]
    local output = {}
 
    output[#output+1] = '第' .. card_arcwitch[cardno][1] .. '期魔女戰 '
 
    if card_arcwitch[cardno][2] == 0 then output[#output+1] = '一般魔女'
    elseif card_arcwitch[cardno][2] == 1 then output[#output+1] = '限定魔女'
    elseif card_arcwitch[cardno][2] == 2 then output[#output+1] = '幻想魔女'
    elseif card_arcwitch[cardno][2] == 5 then output[#output+1] = '創世魔女'
    elseif card_arcwitch[cardno][2] == 9 then output[#output+1] = '排名獎勵'
    end
 
    output[#output+1] = ' (' .. os.date("%Y/%m/%d", card_arcwitch[cardno][3]+28800) .. "~" .. os.date("%Y/%m/%d", card_arcwitch[cardno][4]+28800) ..')'
    output[#output+1] = '<br/>'
 
    return table.concat(output)
end
 
function p.awaken(frame)
    local cardno = frame.args[1]

    if card_awaken[cardno] then
        return card_awaken[cardno][1]
    else
        return ''
    end
end

function p.cat(frame)
    local cardno=frame.args[1]
    local output = {}
    local card_type = {'光', '火', '水', '暗', '特殊'}
    local card_rare_cat = {'N', 'R', 'SR', 'N', 'R', 'SR', 'N', 'UR', 'UR', 'GSR', 'GUR', 'LR', 'LR', 'GLR'}
 
    output[#output+1] = cat_link('稀有度:' .. card_rare_cat[card_data[cardno][3]])
    output[#output+1] = cat_link('屬性:' .. card_type[card_data[cardno][4]])
    output[#output+1] = cat_link(card_type[card_data[cardno][4]] .. card_rare_cat[card_data[cardno][3]])
    output[#output+1] = cat_link('進化次數:' .. card_data[cardno][6])
    if card_arcwitch[cardno] then output[#output+1] = cat_link('魔女戰') end
    if string.sub(cardno, -1) == '2' then output[#output+1] = cat_link('來自進化事故') end
    if card_data[cardno][18] == 202 then output[#output+1] = cat_link('魔女特攻卡') end
 
    return table.concat(output)
end

function deckbonus(cno)
    local deckbonus_data = mw.loadData('Module:deckbonus.data')
    local deckbonus_name = mw.loadData('Module:deckbonus.name')
    local result = {}
    local output = ''

    for key, value in pairs(deckbonus_data[2]) do
        if value[2] == card_data[cno][2] then
            local tmp = {}
            tmp[#tmp+1] = cat_link('組隊獎勵:' .. deckbonus_name[value[1]][2],deckbonus_name[value[1]][2])
            if deckbonus_data[1][value[1]][1] == 1 then
                tmp[#tmp+1] = '(攻擊力+' .. deckbonus_data[1][value[1]][3] .. '%)'
            elseif deckbonus_data[1][value[1]][1] == 0 then
                tmp[#tmp+1] = '(防禦力+' .. deckbonus_data[1][value[1]][3] .. '%)'
            end
            tmp[#tmp+1] = cat_link('組隊獎勵:' .. deckbonus_name[value[1]][2])
            result[#result+1] = table.concat(tmp)
        end
    end

    if #result > 0 then
        return '組隊獎勵:' .. table.concat(result, '<br/>     ')
    end
end

-- adh: atk=14, def=16, hp=12
function para_calc(cno, adh, evo)
    local card_para = {0, 0, 0, 0, 0}
    local cno_orig = cno
    local p_fix-- = para_fix(cno, adh, evo)

    if cno_orig == '07641' or cno_orig == '08571' or cno_orig == '09041' or string.sub(cno_orig,1,4) == '1792' or cno_orig == '19256' or cno_orig == '24151' or cno_orig == '24191' or cno_orig == '23800' then
        local cdata = {
            ['07641'] = {[12]=10859, [14]=9174, [16]=8932},
            ['08571'] = {[12]=10848, [14]=9069, [16]=9153},
            ['09041'] = {[12]=10449, [14]=9259, [16]=9069},
            ['17921'] = {[12]=15512, [14]=14981, [16]=13298},
            ['17926'] = {[12]=21060, [14]=20557, [16]=18103},
            ['19256'] = {[12]=24783, [14]=26371, [16]=22852},
            ['24151'] = {[12]=8920, [14]=8920, [16]=8920},
            ['24191'] = {[12]=12560, [14]=12560, [16]=12560},
            ['23800'] = {[12]=9274, [14]=9274, [16]=9274},
            ['23810'] = {[12]=51744, [14]=51743, [16]=46733}}
--            ['16526'] = {[12]=22529, [14]=22040, [16]=21424},
--            ['16546'] = {[12]=22041, [14]=22404, [16]=22456},
--            ['16806'] = {[12]=23207, [14]=22477, [16]=22196},
--            ['16836'] = {[12]=23997, [14]=23100, [16]=22955},
--            ['17136'] = {[12]=23171, [14]=22642, [16]=22490},
--            ['17186'] = {[12]=23325, [14]=23537, [16]=21438},
--            ['17156'] = {[12]=25325, [14]=25487, [16]=23438},
--            ['17536'] = {[12]=26310, [14]=26088, [16]=23938},
--            ['17546'] = {[12]=23090, [14]=24538, [16]=21752}}
        return cdata[cno_orig][adh]
--    elseif card_data[cno][3] == 11 and card_data[cno][7] == 2 and card_fusion[cno] then
    elseif card_data[cno][3] == 11 and card_data[string.sub(cno,0,4)..'0'] == nil and card_fusion[cno] then
        p_fix = para_fix(cno, adh, evo)
        local para_fg = card_data[cno][adh]

        para_fg = card_data[cno][adh]
            + math.floor(para_calc(card_fusion[cno][1], adh, card_data[card_fusion[cno][1]][7])*0.08)
            + math.floor(para_calc(card_fusion[cno][2], adh, card_data[card_fusion[cno][2]][7])*0.08)
        if card_fusion[cno][3] ~= '' then
            para_fg = para_fg + math.floor(para_calc(card_fusion[cno][3], adh, card_data[card_fusion[cno][3]][7])*0.08)
        end
        if card_fusion[cno][4] ~= '' then
            para_fg = para_fg + math.floor(para_calc(card_fusion[cno][3], adh, card_data[card_fusion[cno][4]][7])*0.08)
        end

        --return para_fix(cno, adh, 1) .. '/' .. cno .. '/' .. adh
        --return para_calc(card_fusion[cno][1], adh, card_data[card_fusion[cno][1]][7])
        return para_fg
    else
        p_fix = para_fix(cno, adh, evo)
        if card_data[cno][7] ~= 0 and card_data[string.sub(cno, 0, 4) .. '0'] then cno = string.sub(cno, 0, 4) .. '0' end
--    if string.sub(cno, 0, 4) == '0764' or string.sub(cno, 0, 4) == '0857' or string.sub(cno, 0, 4) == '0904' then card_data[cno][adh] = 0 end

        if card_data[cno] then
            card_para[0] = p_fix + card_data[cno][adh]
        end

        if card_data[cno][7] == card_data[cno][6] then
            --card_para[0] = p_fix
            card_para[evo] = card_data[cno][adh] + p_fix
 
        else
            if string.sub(cno_orig, -1) == '2' then
--                card_para[0] = card_data[cno][adh] + p_fix
                card_para[1] = card_data[cno_orig][adh] + math.floor(card_para[0] * 0.15) * 2
            else
--                card_para[0] = card_data[cno][adh] + p_fix
                --card_para[evo] = card_data[cno][adh]

                for i = 1, card_data[cno][6] do
                    card_para[i] = card_data[card_data[cno][8]][adh] + math.floor(card_para[i-1] * 0.15) * 2
                    cno = card_data[cno][8]
                end
            end
        end
 
        if card_data[cno_orig][6] ~= -1 and evo > card_data[cno_orig][6] then
            if card_data[string.sub(cno_orig, 0, 4) .. '0'][7] == 1 then
                card_para[evo] = card_data[cno_orig][adh] + p_fix
            else
                if evo == 3 then
                    card_para[evo] = card_data[cno_orig][adh] + math.floor(card_para[0] * 0.15) * 2
                else
                    card_para[evo] = card_data[cno_orig][adh] + math.floor(card_para[evo-2] * 0.15) * 2
                end
            end
        end

        return card_para[evo]
    end
end
 
function para_base(cno, adh, evo)
    local card_para = {0, 0, 0, 0, 0}
    local cno_orig = cno
 
    if card_data[cno][7] ~= 0 then cno = string.sub(cno, 0, 4) .. '0' end
    --card_para[0] = para_fix(cno, adh, evo)
 
    if card_data[cno][7] == card_data[cno][6] then
        card_para[evo] = card_data[cno][adh]
        --card_para[0] = 0
    else
        if string.sub(cno_orig, -1) == '2' then
            card_para[0] = card_data[cno][adh]
            card_para[1] = card_data[cno_orig][adh] + math.floor(card_para[0] * 0.15) * 2
        else
            card_para[0] = card_data[cno][adh]
            --card_para[evo] = card_data[cno][adh]
 
            for i = 1, card_data[cno][6] do
                card_para[i] = card_data[card_data[cno][8]][adh] + math.floor(card_para[i-1] * 0.15) * 2
                cno = card_data[cno][8]
            end
 
        end
    end
--[[
    if evo > card_data[cno_orig][6] then
        card_para[evo] = card_data[cno_orig][adh] + math.floor(card_para[0] * 0.15) * 2
    end
--]]
    return card_para[evo]
end
 
function para_fix(cno, adh, evo)
    local para_fix = 0
    local cno_orig = cno
 
    cno = string.sub(cno, 0, 4) .. '0'
 
    if card_fusion[cno] then
        para_fix = math.floor(para_base(card_fusion[cno][1], adh, card_data[card_fusion[cno][1]][7]) * 0.08)
        para_fix = para_fix + math.floor(para_base(card_fusion[cno][2], adh, card_data[card_fusion[cno][2]][7]) * 0.08)
        if string.len(card_fusion[cno][3]) > 0 then
            para_fix = para_fix + math.floor(para_base(card_fusion[cno][3], adh, card_data[card_fusion[cno][3]][7]) * 0.08)
        end
        if string.len(card_fusion[cno][4]) > 0 then
            para_fix = para_fix + math.floor(para_base(card_fusion[cno][4], adh, card_data[card_fusion[cno][4]][7]) * 0.08)
        end
    end
 
    if string.sub(cno_orig, 0, 4) == '1438' then
        if adh == 14 then para_fix = 2255
        elseif adh == 16 then para_fix = 2347
        elseif adh == 12 then para_fix = 2660
        end
    end
 
    if string.sub(cno_orig, 0, 4) == '1555' then
        if adh == 14 then para_fix = 1757
        elseif adh == 16 then para_fix = 1742
        elseif adh == 12 then para_fix = 1856
        end
    end

    if cno_orig == '02161' then
        if adh == 14 then para_fix = 406
        elseif adh == 16 then para_fix = 406
        elseif adh == 12 then para_fix = 372
        end
    end
 
    if string.sub(cno_orig, 0, 4) == '1736' then
        if adh == 14 then para_fix = 1305
        elseif adh == 16 then para_fix = 1305
        elseif adh == 12 then para_fix = 1747
        end
    end

    if string.sub(cno_orig, 0, 4) == '1801' then
        if adh == 14 then para_fix = 1060
        elseif adh == 16 then para_fix = 1064
        elseif adh == 12 then para_fix = 1428
        end
    end

    return para_fix
end

function s_name(s)
    s = string.gsub(s, '<img=48>', '攻擊')
    s = string.gsub(s, '<img=51>', '攻防')
    return s
end

return p

您使用了广告屏蔽软件!


Wikia通过广告运营为用户提供免费的服务。我们对用户通过嵌入广告屏蔽软件访问网站进行了使用调整。

如果您使用了广告屏蔽软件,将无法使用我们的服务。请您移除广告屏蔽软件,以确保页面正常加载。

查看其他FANDOM

随机维基