此模块的文档可以在Module:Info/doc创建
local p = {}
local card_name = mw.loadData('Module:card.name')
local card_data = mw.loadData('Module:card.data')
local skill_name = mw.loadData('Module:skill.name')
function p.arcwitch(frame)
local cno = frame.args[1]
local cat = frame.args[2] or '1'
local output = {}
local aw = {}
aw['0'] = '一般魔女'
aw['1'] = '限定魔女'
aw['2'] = '幻想魔女'
aw['3'] = '創世魔女'
output[#output+1] = '<div class="ib-arcwitch" style="float:left; text-align:left; border:1px solid #bcc1c4; background-color:#e4eef2; margin-left:1px; margin-right:1px; margin-bottom:2px; padding:5px;">'
output[#output+1] = '<table><tr>'
output[#output+1] = '<td>[[file:icon_' .. cno .. '.png|128px|link=' .. card_name[cno][2] .. ']]</td>'
output[#output+1] = '<td width="100%" style="vertical-align:text-top;">'
output[#output+1] = '<font size=2>' .. aw[cat] .. '</font><hr>'
output[#output+1] = '<font size=5>[[' .. card_name[cno][2] .. ']]</font>'
output[#output+1] = '</td></tr></table></div>'
return table.concat(output)
end
function p.witchgate(frame)
local cno = frame.args[1]
local output = {}
output[#output+1] = '<div class="ib-sp_atk" style="float:left; text-align:left; border:1px solid #bcc1c4; background-color:#e4eef2; margin-left:1px; margin-right:1px; margin-bottom:2px; padding:5px;">'
output[#output+1] = '<table><tr>'
output[#output+1] = '<td>[[file:icon_' .. cno .. '.png|64px|link=' .. card_name[cno][2] .. ']]</td>'
output[#output+1] = '<td width="100%" style="vertical-align:text-top;">'
output[#output+1] = '<font size=2>魔女之扉</font><hr>'
output[#output+1] = '<font size=4>[[' .. card_name[cno][2] .. ']]</font>'
output[#output+1] = '</td></tr></table></div>'
return table.concat(output)
end
function p.sp_atk(frame)
local cno = frame.args[1]
--local cat = frame.args[2]
local output = {}
output[#output+1] = '<div class="ib-sp_atk" style="float:left; text-align:left; border:1px solid #bcc1c4; background-color:#e4eef2; margin-left:1px; margin-right:1px; margin-bottom:2px; padding:5px; font-size:14px; line-height:22px;">'
output[#output+1] = '<table><tr>'
output[#output+1] = '<td>[[file:icon_' .. cno .. '.png|64px|link=' .. card_name[cno][2] .. ']]</td>'
output[#output+1] = '<td width="100%" style="vertical-align:text-top;">'
if card_data[cno][19] ~= -1 then
local sk_name = string.gsub(skill_name[card_data[cno][19]][2],'<img=51>','攻防')
output[#output+1] = '<font size=2>' .. sk_name .. '</font><hr>'
else
output[#output+1] = '<font size=2>-</font><hr>'
end
output[#output+1] = '<font size=4>[[' .. card_name[cno][2] .. ']]</font>'
output[#output+1] = '</td></tr></table></div>'
return table.concat(output)
end
function p.preview(frame)
local cno = frame.args[1]
local ctype = frame.args[2]
local cname = frame.args[3]
local cskill = frame.args[4]
local output = {}
local aw = {}
aw['0'] = '一般魔女'
aw['1'] = '限定魔女'
aw['2'] = '幻想魔女'
aw['3'] = '創世魔女'
aw['4'] = '排名獎勵'
aw['5'] = '特殊報酬'
output[#output+1] = '<div class="ib-sp_atk" style="float:left; text-align:left; border:1px solid #bcc1c4; background-color:#e4eef2; margin-left:1px; margin-right:1px; margin-bottom:2px; padding:5px; font-size:14px; line-height:22px;">'
output[#output+1] = '<table><tr>'
output[#output+1] = '<td>[[file:cd_' .. cno .. '.png|80px|link=]]</td>'
output[#output+1] = '<td width="100%" style="vertical-align:text-top;">'
output[#output+1] = '<font size=2>' .. aw[ctype] .. '</font><hr>'
output[#output+1] = '<font size=4>' .. cname .. '</font><br/>' .. cskill
output[#output+1] = '</td></tr></table></div>'
return table.concat(output)
end
function p.event(frame)
local tl = frame.args[1]
local stime = frame.args[2]
local etime = frame.args[3]
local card0 = frame.args[4]
local card1 = frame.args[5]
local output = {}
output[#output+1] = '<table border="0" cellpadding="1" cellspacing="1" class="article-table article-table-selected" style="width:100%; position:relative; margin-top: 0px; margin-bottom: 0px; font-size:14px; line-height:22px;">'
output[#output+1] = '<tr><td style="vertical-align:text-top;">'
--icon
if card1 ~= nil then
output[#output+1] = '<div style="position:absolute; bottom:20px; right:190px;">'
local i = 5
while frame.args[i] ~= nil do
output[#output+1] = '[[file:icon_' .. frame.args[i] ..'.png|48px|link=' .. card_name[frame.args[i]][2] .. ']]'
i = i + 1
end
output[#output+1] = '</div>'
end
output[#output+1] = '<br/><span style="font-size:28px; line-height:28px;">[[活動/' .. tl .. '|' .. tl .. ']]</span><hr>'
output[#output+1] = '開始時間:' .. os.date("%Y/%m/%d %H:%M:%S", stime) .. ' (UTC+8)<br/>'
output[#output+1] = '結束時間:' .. os.date("%Y/%m/%d %H:%M:%S", etime) .. ' (UTC+8)<br/>'
if stime - 28800 > os.time() then
output[#output+1] = countdown(stime - 28800, 1)
else
if etime - 28800 >= os.time() then
output[#output+1] = countdown(etime - 28800, 0)
elseif etime - 28800 < os.time() and etime - 28800 > os.time() + 86400 then
output[#output+1] = '<span style="color:red;">活動已結束</span>'
end
end
output[#output+1] = '</td>'
if card0 ~= nil then
if mw.title.new('file:cd_' .. card0 .. '.png').exists then
output[#output+1] = '<td style="width:162px; text-align:center;">[[file:cd_' .. card0 .. '.png|160px|link=' .. card_name[card0][2] .. ']]</td>'
else
output[#output+1] = '<td style="width:162px; text-align:center;">[[file:NoImage.png|160px|link=' .. card_name[card0][2] .. ']]</td>'
end
else
output[#output+1] = '<td style="width:162px; text-align:center;">[[file:NoImage.png|160px|link=]]</td>'
end
output[#output+1] = '</tr></table>'
return table.concat(output)
end
function countdown(t, p)
local cnt = t - os.time()
local output = {}
output[#output+1] = '<span style="color:#FF0000;">' .. math.floor(cnt / 86400) .. '</span>日'
output[#output+1] = '<span style="color:#FF0000;">' .. math.floor((cnt - math.floor(cnt / 86400) * 86400) / 3600) .. '</span>小時'
output[#output+1] = '<span style="color:#FF0000;">' .. math.mod(math.floor((cnt - math.floor(cnt / 86400) * 86400) / 60), 60) .. '</span>分鐘'
if p == 0 then output[#output+1] = '後活動結束' elseif p == 1 then output[#output+1] = '後活動開始' end
return table.concat(output)
end
function p.mutiple(frame)
local cno
local i = 1
local output = {}
output[#output+1] = '<table border="0" cellpadding="1" cellspacing="1" class="article-table" style="float: center; width: 100%; margin-top: 2px; margin-bottom: 2px;"><tr><th>有多張同名的卡片</th></tr></table>'
while frame.args[i] ~= nil do
cno = frame.args[i]
output[#output+1] = '<div class="ib-mutiple" style="float:left; text-align:left; border:1px solid #bcc1c4; background-color:#e4eef2; margin-left:1px; margin-right:1px; margin-bottom:2px; padding:5px;font-size: 14px; line-height: 22px;">'
output[#output+1] = '<table><tr>'
output[#output+1] = '<td>[[file:icon_' .. cno .. '.png|128px|link=' .. cno .. ']]</td>'
output[#output+1] = '<td width="100%" style="vertical-align:text-top;">'
output[#output+1] = '<span style="font-size: 14px; line-height: 22px;">Card No. ' .. cno .. '</span><hr>'
output[#output+1] = '<span style="font-size: 24px; line-height: 24px;">[[' .. cno .. '|' .. card_name[cno][2] .. '<br/>' .. card_name[cno][1] .. ']]</span>'
output[#output+1] = '</td></tr></table></div>'
i = i + 1
end
return table.concat(output)
end
function p.icon(frame)
local cno = frame.args[1]
local w = frame.args[2] or 48
local link = frame.args[3] or 0
local txt = frame.args[4] or 0
local output = {}
if w == '' then w = 48 end
if link == '' then link = 0 end
if txt == '' then txt = 0 end
-- if mw.title.new('file:icon_' .. cno .. '.png').exists then
output[#output+1] = '[[file:icon_' .. cno .. '.png|' .. w .. 'px|link='
-- else
-- output[#output+1] = '[[file:icon_00000.png|' .. w .. 'px|link='
-- end
if link == '1' then output[#output+1] = card_name[cno][2] end
output[#output+1] = ']]'
if txt == '1' then
if link == '1' then
output[#output+1] = ' [[' .. card_name[cno][2] .. ']]'
else
output[#output+1] = ' ' .. card_name[cno][2]
end
end
return table.concat(output)
end
function p.img(frame)
local cno = frame.args[1]
local w = frame.args[2] or 160
local link = frame.args[3] or 0
local output = {}
if mw.title.new('file:cd_' .. cno .. '.png').exists then
output[#output+1] = '[[file:cd_' .. cno .. '.png|' .. w .. 'px|link='
else
output[#output+1] = '[[file:NoImage.png|' .. w .. 'px|link='
end
if link == '1' then output[#output+1] = card_name[cno][2] end
output[#output+1] = ']]'
return table.concat(output)
end
return p