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

提供: Wikiducca
移動: 案内検索
(一時保存)
(1版)
 
(2人の利用者による、間の27版が非表示)
行1: 行1:
local p = {}
+
--[[category:唯一の編集者により削除が依頼されているページ]]
 
+
function border(x,y)
+
if x == y or (x == '<>' and (y == '<' or y == '>')) 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 td(n1, n2, n3, n4, bye1, prv1, bye2, prv2, top, cur, btm, note)
+
local colspan1 = ''
+
local colspan2 = ''
+
+
if bye1~=nil then
+
colspan1 = '" colspan="'..(bye1 * 4 + 1)
+
end
+
if bye2~=nil then
+
colspan2 = '" colspan="'..(bye2 * 4 + 1)
+
end
+
+
return {
+
'<td rowspan="'..n1..colspan1..'" style="border-bottom:'..border('<',prv)..'"></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('<',prv)..'"></td>'..
+
'<td rowspan="'..n2..'"></td>',
+
+
'<td rowspan="'..n3..'" style="border-right:'..border('>',prv)..'"></td>'..
+
'<td rowspan="'..n3..'" style="border-top:'..border('<>',prv)..'"></td>'..
+
'<td rowspan="'..n3+n4..'" style="vertical-align:top;border-top:'..border('<>',prv)..'">'..btm..'</td>',
+
+
'<td colspan="'..n4..colspan2..'" style="border-top:'..border('>',prv)..'"></td>'..
+
'<td colspan="'..n4..'"></td>'
+
}
+
end
+
 
+
function p.main(frame)
+
local args = frame.args
+
local t = {}
+
+
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 = 0
+
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
+
+
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
+
i = i + 1
+
+
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
+
if prv2 > prv3 then
+
cur1 = (prv2 + prv3 + (cur1 % 2)) / 2
+
else
+
cur1 = (prv2 + prv3 - (cur1 % 2)) / 2
+
end
+
local cur2 = (prv2 + prv3) - cur1
+
data[rnd][cur] = {top = cur1, btm = cur2, res = args[i+1]}
+
+
local temp = th1(
+
prv1, cur1, prv1 + prv2 + prv3, cur1 + cur2,
+
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]
+
)
+
row = row + cur1 + cur2
+
+
+
+
i = i + 4
+
end
+
if row == nTeam * 2 then
+
rnd = rnd + 1
+
cur = 1
+
prv = 1
+
row = 0
+
data[rnd] = {}
+
else
+
curr = curr + 1
+
end
+
end
+
end
+
 
+
return p
+

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

--