FANDOM


local p = {}

local card = require("Module:card")
local skill = require("Module:skill")

local card_data = mw.loadData('Module:card.data')
local card_name = mw.loadData('Module:card.name')
local card_awaken = mw.loadData('Module:card.awaken')
local card_fusion = mw.loadData('Module:card.fusion')

local skill_data = mw.loadData('Module:skill.data')

local card_rare = {'N', 'R', 'SR', 'HN', 'HR', 'HSR', 'N', 'UR', 'HUR', 'GSR', 'GUR', 'LR', 'HLR', 'GLR'}
local ctype = {'光', '火', '水', '暗', '特殊'}

function sortDesc(a, b) return b[1] < a[1] end

function sortCard(card_idx, sortBy)
    local res = {}
    table.sort(card_idx, sortBy)
    for key, value in ipairs(card_idx) do
        res[#res+1] = value[2]
    end
    return table.concat(res)
end

function p.cardlist(frame)
    local icon = frame.args[1] or 0
    local last = frame.args[2] or 1
    local attr_card = frame.args[3] or 0
    local attr_dmg = frame.args[4] or 0
    local attr_target = frame.args[5] or 0
    local eid = frame.args[6] or 0
    local card_idx = {}
    local res = {}

    if last == '1' then last = -1 else last = 0 end
    if attr_dmg == "" then attr_dmg = 0 end
    if attr_card == "" then attr_card = 0 end
    if attr_target == "" then attr_target = 0 end
    if frame.args[6] == "" or frame.args[6] == nil then
        frame.args[6] = 0 eid = 0
    elseif frame.args[6] == '-1' then
        local eid2 = {3, 13, 14, 17, 22, 27, 28, 34, 35, 38}
        for i = 1, #eid2 do
            frame.args[i+5] = eid2[i]
        end
        frame.args[#eid2+6] = nil
    elseif frame.args[6] == '-2' then
        local eid2 = {1, 4, 5, 6, 7, 8, 10, 11, 12, 15, 16, 23, 24, 25, 26, 30, 33}
        for i = 1, #eid2 do
            frame.args[i+5] = eid2[i]
        end
        frame.args[#eid2+6] = nil
    end

    res[#res+1] = '<table border="0" cellpadding="1" cellspacing="1" class="wikitable sortable datalist" style="font-size:14px; line-height:22px;"><tr><th>S/N</th>'
    if icon == '1' then res[#res+1] = '<th>頭像</th>' end
    res[#res+1] = '<th>card#</th><th>卡片名稱</th><th>屬性</th><th>稀有度</th><th>cost</th><th>攻擊</th><th>防禦</th><th>兵力</th><th>發動</th><th data-sort-type="number">機率</th><th>目標</th><th>主要效果</th><th data-sort-type="number">m.val</th><th>附加效果</th><th data-sort-type="number">s.val</th><th>最大次數</th></tr>'
    local ptimea = os.clock()
    for key, value in pairs(card_data) do
        local a = eid*1
        if value[17] ~= -1 and key ~= '04111' then
            local i = 6
            repeat
                if value[26] == 0 and (skill_data[value[17]][15] == frame.args[i]*1 or a == 0)
                    and (value[8] == last or last == 0)
                    and (value[4] == attr_card*1 or attr_card*1 == 0)
                    and (skill_data[value[17]][16] == attr_dmg*1 or attr_dmg*1 == 0)
                    and (skill_data[value[17]][25] == attr_target*1 or attr_target*1 == 0) then
                    local res_tmp = {}
                    res_tmp[#res_tmp+1] = '<tr><td>'
                    res_tmp[#res_tmp+1] = value[1]
                    res_tmp[#res_tmp+1] = '</td>'
                    if icon == '1' then
                        res_tmp[#res_tmp+1] = '<td>[[file:icon_'
                        res_tmp[#res_tmp+1] = key
                        res_tmp[#res_tmp+1] = '.png|64px|link=]]</td>' 
                    end
                    res_tmp[#res_tmp+1] = '<td>'
                    res_tmp[#res_tmp+1] = key
                    res_tmp[#res_tmp+1] = '</td><td>[['
                    res_tmp[#res_tmp+1] = card_name[key][2]
                    res_tmp[#res_tmp+1] = ']]<br/>[['
                    res_tmp[#res_tmp+1] = card_name[key][1]
                    res_tmp[#res_tmp+1] = ']]</td><td>'
                    res_tmp[#res_tmp+1] = ctype[value[4]]
                    res_tmp[#res_tmp+1] = '</td><td>'
                    res_tmp[#res_tmp+1] = card_rare[value[3]]
                    res_tmp[#res_tmp+1] = '</td><td>'
                    res_tmp[#res_tmp+1] = value[5]
                    res_tmp[#res_tmp+1] = '</td><td>'
                    res_tmp[#res_tmp+1] = card.para_calc{args={key, 14, value[7]}}
                    res_tmp[#res_tmp+1] = '</td><td>'
                    res_tmp[#res_tmp+1] = card.para_calc{args={key, 16, value[7]}}
                    res_tmp[#res_tmp+1] = '</td><td>'
                    res_tmp[#res_tmp+1] = card.para_calc{args={key, 12, value[7]}}
                    res_tmp[#res_tmp+1] = '</td>'
                    res_tmp[#res_tmp+1] = skill.skill_1{args={value[17], 0, 0, 1}}
                    res_tmp[#res_tmp+1] = '</tr>\n'
                    card_idx[#card_idx+1] = {value[1], table.concat(res_tmp)}
                end
                i = i + 1
            until frame.args[i] == nil or a == 0
        end
    end
    local ptimeb = os.clock()

--    table.sort(card_idx, sortDesc)
--    for key, value in ipairs(card_idx) do
--        res[#res+1] = value[2]
--    end

    res[#res+1] = sortCard(card_idx, sortDesc)
    local ptimec = os.clock()
    res[#res+1] = '</table>'
--[[
    res[#res+1] = 'list:'
    res[#res+1] = ptimeb-ptimea
    res[#res+1] = ' / sorting:'
    res[#res+1] = ptimec-ptimeb
    res[#res+1] = ' / '
    res[#res+1] = #card_data
--]]
    --return table.concat(res)
end

--新卡列表專用
function p.newcardlist(frame)
    local icon = frame.args[1] or 0
    local last = frame.args[2] or 1
    local card_idx = {}
    local res = {}

    if last == '1' then last = -1 else last = 0 end

    for key, value in pairs(card_data) do
        card_idx[#card_idx+1] = {value[1],key}
    end
    table.sort(card_idx, sortDesc)

    res[#res+1] = '<table border="0" cellpadding="1" cellspacing="1" class="wikitable datalist" style="font-size:14px; line-height:22px;"><tr><th>S/N</th>'
    if icon == '1' then res[#res+1] = '<th>頭像</th>' end
    res[#res+1] = '<th>card#</th><th>卡片名稱</th><th>屬性</th><th>稀有度</th></tr>'
    for i=1,100 do
        local key = card_idx[i][2]
        local value = card_data[key]
        if value[17] ~= -1 and key ~= '04111' then
            if value[8] == last or last == 0 then
                local res_tmp = {}
                res_tmp[#res_tmp+1] = '<tr><td>'
                res_tmp[#res_tmp+1] = value[1]
                res_tmp[#res_tmp+1] = '</td>'
                if icon == '1' then
                    res_tmp[#res_tmp+1] = '<td>[[file:icon_'
                    res_tmp[#res_tmp+1] = key
                    res_tmp[#res_tmp+1] = '.png|64px|link=]]</td>'
                end
                res_tmp[#res_tmp+1] = '<td>'
                res_tmp[#res_tmp+1] = key
                res_tmp[#res_tmp+1] = '</td><td>[['
                res_tmp[#res_tmp+1] = card_name[key][2]
                res_tmp[#res_tmp+1] = ']]<br/>[['
                res_tmp[#res_tmp+1] = card_name[key][1]
                res_tmp[#res_tmp+1] = ']]</td><td>'
                res_tmp[#res_tmp+1] = ctype[value[4]]
                res_tmp[#res_tmp+1] = '</td><td>'
                res_tmp[#res_tmp+1] = card_rare[value[3]]
                res_tmp[#res_tmp+1] = '</td></tr>\n'
                res[#res+1] = table.concat(res_tmp)
            end
        end
    end

    res[#res+1] = '</table>'

    --return table.concat(res)
end

function p.awaken(frame)
    local icon = frame.args[1] or 0
    local rare = frame.args[2] or 0
    local attr_card = frame.args[3] or 0
    local card_idx = {}
    local res = {}

    if rare == "" then rare = 0 end
    if attr_card == "" then attr_card = 0 end

    res[#res+1] = '<table border="0" cellpadding="1" cellspacing="1" class="wikitable sortable datalist" style="font-size:14px; line-height:22px;"><tr><th>S/N</th>'
    if icon == '1' then res[#res+1] = '<th>頭像</th>' end
    res[#res+1] = '<th>card#</th><th>卡片名稱</th><th>屬性</th><th>稀有度</th><th>cost</th><th>攻擊</th><th>防禦</th><th>兵力</th><th>發動</th><th data-sort-type="number">機率</th><th>目標</th><th>主要效果</th><th data-sort-type="number">m.val</th><th>附加效果</th><th data-sort-type="number">s.val</th><th>最大次數</th></tr>'
    for key, value in pairs(card_awaken) do
        local cno = value[1]
        if (card_data[cno][3] == rare*1 or rare == 0) and (card_data[cno][4] == attr_card*1 or attr_card*1 == 0) then
            local res_tmp = {}
            res_tmp[#res_tmp+1] = '<tr><td>'
            res_tmp[#res_tmp+1] = card_data[cno][1]
            res_tmp[#res_tmp+1] = '</td>'
            if icon == '1' then
                res_tmp[#res_tmp+1] = '<td>[[file:icon_'
                res_tmp[#res_tmp+1] = key
                res_tmp[#res_tmp+1] = '.png|64px|link=]]</td>'
            end
            res_tmp[#res_tmp+1] = '<td>'
            res_tmp[#res_tmp+1] = cno
            res_tmp[#res_tmp+1] = '</td><td>[['
            res_tmp[#res_tmp+1] = card_name[cno][2]
            res_tmp[#res_tmp+1] = ']]<br/>[['
            res_tmp[#res_tmp+1] = card_name[cno][1]
            res_tmp[#res_tmp+1] = ']]</td><td>'
            res_tmp[#res_tmp+1] = ctype[card_data[cno][4]]
            res_tmp[#res_tmp+1] = '</td><td>'
            res_tmp[#res_tmp+1] = card_rare[card_data[cno][3]]
            res_tmp[#res_tmp+1] = '</td><td>'
            res_tmp[#res_tmp+1] = card_data[cno][5]
            res_tmp[#res_tmp+1] = '</td><td>'
            res_tmp[#res_tmp+1] = card.para_calc{args={cno, 14, card_data[cno][7]}}
            res_tmp[#res_tmp+1] = '</td><td>'
            res_tmp[#res_tmp+1] = card.para_calc{args={cno, 16, card_data[cno][7]}}
            res_tmp[#res_tmp+1] = '</td><td>'
            res_tmp[#res_tmp+1] = card.para_calc{args={cno, 12, card_data[cno][7]}}
            res_tmp[#res_tmp+1] = '</td>'
            res_tmp[#res_tmp+1] = skill.skill_1{args={card_data[cno][17], 0, 0, 1}}
            res_tmp[#res_tmp+1] = '</tr>\n'
            card_idx[#card_idx+1] = {card_data[cno][1], table.concat(res_tmp)}
        end
    end

    res[#res+1] = sortCard(card_idx, sortDesc)
    res[#res+1] = '</table>'
 
    return table.concat(res)
end

function p.fusion(frame)
    local rare = frame.args[1] or 0
    local card_idx = {}
    local res = {}
 
    res[#res+1] = '<table border="0" cellpadding="1" cellspacing="1" class="wikitable datalist"><tr><th>合成卡片</th><th>素材卡片</th></tr>'
 
    for key, value in pairs(card_fusion) do
        if (card_data[key][3] == rare*1 or rare == 0) then
            local res_tmp = {}
            res_tmp[#res_tmp+1] = '<tr><td>[[file:icon_'
            res_tmp[#res_tmp+1] = key
            res_tmp[#res_tmp+1] = '.png|64px|link='
            res_tmp[#res_tmp+1] = key
            res_tmp[#res_tmp+1] = ']] [['
            res_tmp[#res_tmp+1] = key
            res_tmp[#res_tmp+1] = '|'
            res_tmp[#res_tmp+1] = card_name[key][2]
            res_tmp[#res_tmp+1] = ']]</td><td>[[file:icon_'
            res_tmp[#res_tmp+1] = value[1]
            res_tmp[#res_tmp+1] = '.png|64px|link='
            res_tmp[#res_tmp+1] = card_name[value[1]][2]
            res_tmp[#res_tmp+1] = ']] × [[file:icon_'
            res_tmp[#res_tmp+1] = value[2]
            res_tmp[#res_tmp+1] = '.png|64px|link='
            res_tmp[#res_tmp+1] = card_name[value[2]][2]
            res_tmp[#res_tmp+1] = ']]'
            if value[3] ~= '' then
                res_tmp[#res_tmp+1] = ' × [[file:icon_'
                res_tmp[#res_tmp+1] = value[3]
                res_tmp[#res_tmp+1] = '.png|64px|link='
                res_tmp[#res_tmp+1] = card_name[value[3]][2]
                res_tmp[#res_tmp+1] = ']]'
            end
            if value[4] ~= '' then
                res_tmp[#res_tmp+1] = ' × [[file:icon_'
                res_tmp[#res_tmp+1] = value[4]
                res_tmp[#res_tmp+1] = '.png|64px|link='
                res_tmp[#res_tmp+1] = card_name[value[4]][2]
                res_tmp[#res_tmp+1] = ']]'
            end
            res_tmp[#res_tmp+1] = '</td></tr>'
            card_idx[#card_idx+1] = {card_data[key][1], table.concat(res_tmp)}
        end
    end

    res[#res+1] = sortCard(card_idx, sortDesc)
    res[#res+1] = '</table>'
 
    return table.concat(res)
end

function p.trans(frame)
    local rare = frame.args[1] or 0
    local card_idx = {}
    local res = {}

    res[#res+1] = '<table border="0" cellpadding="1" cellspacing="1" class="wikitable datalist"><tr><th>進化事故前</th><th>進化事故後</th></tr>'

    for key, value in pairs(card_data) do
        if (value[3] == rare*1 or rare == 0) and value[9] ~= -1 then
            local res_tmp = {}
            res_tmp[#res_tmp+1] = '<tr><td>[[file:icon_'
            res_tmp[#res_tmp+1] = key
            res_tmp[#res_tmp+1] = '.png|64px|link='
            res_tmp[#res_tmp+1] = card_name[key][2]
            res_tmp[#res_tmp+1] = ']] [['
            res_tmp[#res_tmp+1] = card_name[key][2]
            res_tmp[#res_tmp+1] = ']]</td><td>[[file:icon_'
            res_tmp[#res_tmp+1] = value[9]
            res_tmp[#res_tmp+1] = '.png|64px|link='
            res_tmp[#res_tmp+1] = card_name[value[9]][2]
            res_tmp[#res_tmp+1] = ']] [['
            res_tmp[#res_tmp+1] = card_name[value[9]][2]
            res_tmp[#res_tmp+1] = ']]</td></tr>'
            card_idx[#card_idx+1] = {value[1], table.concat(res_tmp)}
        end
    end

    res[#res+1] = sortCard(card_idx, sortDesc)
    res[#res+1] = '</table>'

    return table.concat(res)
end

return p

您使用了广告屏蔽软件!


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

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

查看其他FANDOM

随机维基