「ノート:Tournament」の版間の差分

提供: Wikiducca
移動: 案内検索
(1版)
 
(2人の利用者による、間の4版が非表示)
行1: 行1:
local p = {}
+
--[[category:唯一の編集者により削除が依頼されているページ]]
 
+
function border(x,y,z,w,r)
+
if x == y or (x == '<>' and (y == '<' or y == '>') or (r == 1 and z == w)) then
+
return '4px solid red'
+
else
+
return '2px solid gray'
+
end
+
end
+
 
+
local th2 = '<tr style="height:0.5em">'
+
function th1(x)
+
return th2..'<th rowspan="2" style="text-align:right;border-bottom:4px solid transparent">'..x..'</th>'
+
end
+
 
+
function td1(rnd, n1, n2, n3, n4, bye1, prv1, bye2, prv2, top, cur, btm, note)
+
return {
+
'<td rowspan="'..n1..'" colspan="'..((bye1 or 0)*4+2)..'" style="border-bottom:'..border('<>',prv1,'<',cur,rnd-(bye1 or 0))..'"></td>'..
+
'<td rowspan="'..n1..'"></td>'..
+
'<td rowspan="'..n1+n2..'" style="vertical-align:bottom;">'..top..'</td>',
+
+
'<td rowspan="'..n2+n3..'" style="text-align:right">'..note..'</td>'..
+
'<td rowspan="'..n2..'" style="border-right:'..border('<',cur)..'"></td>'..
+
'<td rowspan="'..n2..'"></td>',
+
+
'<td rowspan="'..n3..'" style="border-right:'..border('>',cur)..'"></td>'..
+
'<td rowspan="'..n3..'" style="border-top:'..border('<>',cur)..'"></td>'..
+
'<td rowspan="'..n3+n4..'" style="vertical-align:top;border-top:'..border('<>',cur)..'">'..btm..'</td>',
+
+
'<td rowspan="'..n4..'" colspan="'..((bye2 or 0)*4+2)..'" style="border-top:'..border('<>',prv2,'>',cur,rnd-(bye2 or 0))..'"></td>'..
+
'<td rowspan="'..n4..'"></td>'
+
}
+
end
+
 
+
function td2(bye,n)
+
if (bye or 0) == 0 then
+
return ''
+
else
+
return '<td data-a="" rowspan="'..n..'" colspan="'..(bye*4)..'"></td>'
+
end
+
end
+
 
+
function p.main(frame)
+
local args = frame.args
+
local t = {}
+
local data = { [0] = {} }
+
+
local i = 1
+
while args[i] ~= 'result' do
+
data[0][i] = {top = 1, btm = 1}
+
t[2*i-1] = th1(args[i])
+
t[2*i] = th2
+
i = i + 1
+
end
+
local nTeam = i - 1
+
i = i + 1
+
+
local rnd = 1
+
local cur = 1
+
local prv = 1
+
local row = 1
+
data[1] = {}
+
while args[i] ~= nil do
+
if args[i] == 'bye' then
+
data[rnd][cur] = data[rnd-1][prv]
+
data[rnd][cur].nBye = (data[rnd-1][prv].nBye or 0) + 1
+
prv = prv + 1
+
row = row + data[rnd][cur].top + data[rnd][cur].btm
+
i = i + 1
+
+
elseif data[rnd-1][prv+1] == nil then
+
data[rnd][cur] = data[rnd-1][prv]
+
data[rnd][cur].nBye = (data[rnd-1][prv].nBye or 0) + 1
+
prv = prv + 1
+
row = row + data[rnd][cur].top + data[rnd][cur].btm
+
+
else
+
local prv1 = data[rnd-1][prv].top
+
local prv2 = data[rnd-1][prv].btm
+
local prv3 = data[rnd-1][prv+1].top
+
local prv4 = data[rnd-1][prv+1].btm
+
local cur1 = prv2 + prv3
+
if prv2 > prv3 then
+
cur1 = prv1 + (cur1 + (cur1 % 2)) / 2
+
else
+
cur1 = prv1 + (cur1 - (cur1 % 2)) / 2
+
end
+
local cur2 = (prv1 + prv2 + prv3 + prv4) - cur1
+
data[rnd][cur] = {top = cur1, btm = cur2, res = args[i+1]}
+
+
local temp = td1(
+
rnd, prv1, cur1 - prv1, prv1 + prv2 + prv3 - cur1, cur1 + cur2 - prv1 - prv2 - prv3,
+
data[rnd-1][prv].nBye, data[rnd-1][prv].res,
+
data[rnd-1][prv+1].nBye, data[rnd-1][prv+1].res,
+
args[i], args[i+1], args[i+2], args[i+3]
+
)
+
+
t[row] = t[row]..temp[1]
+
t[row+prv1] = t[row+prv1]..td2(data[rnd-1][prv].nBye,prv2)..temp[2]
+
t[row+prv1+prv2] = t[row+prv1+prv2]..td2(data[rnd-1][prv+1].nBye,prv3)
+
t[row+cur1] = t[row+cur1]..temp[3]
+
t[row+prv1+prv2+prv3] = t[row+prv1+prv2+prv3]..temp[4]
+
+
prv = prv + 2
+
row = row + cur1 + cur2
+
i = i + 4
+
end
+
if row == nTeam * 2 + 1 then
+
if cur == 1 then
+
break
+
end
+
rnd = rnd + 1
+
cur = 1
+
prv = 1
+
row = 1
+
data[rnd] = {}
+
else
+
cur = cur + 1
+
end
+
end
+
+
local text = ''
+
for i = 1, nTeam * 2 do
+
text = text..t[i]..'</tr>'
+
end
+
return text
+
end
+
 
+
return p
+

2019年2月5日 (火) 22:02時点における最新版

--