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

提供: Wikiducca
移動: 案内検索
(一時保存)
行38: 行38:
 
'<td rowspan="'..n3+n4..'" style="vertical-align:top;border-top:'..border('<>',prv)..'">'..btm..'</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 rowspan="'..n4..colspan2..'" style="border-top:'..border('>',prv)..'"></td>'..
'<td colspan="'..n4..'"></td>'
+
'<td rowspan="'..n4..'"></td>'
 
}
 
}
 +
end
 +
 +
function td2(x,y)
 +
return '<td rowspan="'..y..'" colspan="'..(x*4)..'"></td>'
 
end
 
end
  
行60: 行64:
 
local cur = 1
 
local cur = 1
 
local prv = 1
 
local prv = 1
local row = 0
+
local row = 1
 
data[1] = {}
 
data[1] = {}
 
while args[i] ~= nil do
 
while args[i] ~= nil do
行90: 行94:
 
data[rnd][cur] = {top = cur1, btm = cur2, res = args[i+1]}
 
data[rnd][cur] = {top = cur1, btm = cur2, res = args[i+1]}
 
 
local temp = th1(
+
local temp = td1(
prv1, cur1, prv1 + prv2 + prv3, cur1 + cur2,
+
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].nBye, data[rnd-1][prv].res,
 
data[rnd-1][prv+1].nBye, data[rnd-1][prv+1].res,
 
data[rnd-1][prv+1].nBye, data[rnd-1][prv+1].res,
 
args[i], args[i+1], args[i+2], args[i+3]
 
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]..td(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]
 
row = row + cur1 + cur2
 
row = row + cur1 + cur2
 
 
 
 
i = i + 4
 
i = i + 4
 
end
 
end
if row == nTeam * 2 then
+
if row == nTeam * 2 + 1 then
 
rnd = rnd + 1
 
rnd = rnd + 1
 
cur = 1
 
cur = 1
 
prv = 1
 
prv = 1
row = 0
+
row = 1
 
data[rnd] = {}
 
data[rnd] = {}
 
else
 
else
行112: 行119:
 
end
 
end
 
end
 
end
 +
 +
local text = ''
 +
for i = 1, nTeam * 2 do
 +
text = text..'<tr style="height:0.5em">'..t[i]..'</tr>'
 +
end
 +
return text
 
end
 
end
  
 
return p
 
return p

2017年11月11日 (土) 12:11時点における版

local p = {}

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 rowspan="'..n4..colspan2..'" style="border-top:'..border('>',prv)..'"></td>'.. '<td rowspan="'..n4..'"></td>' } end

function td2(x,y) return '<td rowspan="'..y..'" colspan="'..(x*4)..'"></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 = 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

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 = td1( 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]..td(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] row = row + cur1 + cur2 i = i + 4 end if row == nTeam * 2 + 1 then rnd = rnd + 1 cur = 1 prv = 1 row = 1 data[rnd] = {} else curr = curr + 1 end end

local text = for i = 1, nTeam * 2 do text = text..'<tr style="height:0.5em">'..t[i]..'</tr>' end return text end

return p