ノート:Tournament

提供: Wikiducca
2017年10月27日 (金) 22:23時点におけるかにふとん (ノート | 投稿記録)による版

移動: 案内検索

local p = {}

local wBorder = '4px solid red' local lBorder = '2px solid gray'

function td2(x, round) local t = {} local z if x.z == 0 then z = lBorder else z = wBorder end t[1] = '<td rowspan="'..x.e..'" colspan="4" style="border-bottom:'..z..'"></td>' t[2] = '<td rowspan="'..x.f..'" colspan="4"></td>' return t end

function p.main(frame) local args = frame.args local team = {} local nRow = { [0] = {} } local line = {}

local i = 1 while args[i] ~= "result" do team[i] = args[i] data[0][i] = {a = 1, b = 1} line[2*i-1] = "" line[2*i] = "" i = i + 1 end local nTeam = i - 1 i = i + 1

local round = 1 local curr = 1 local prev = 1 local row = 0 data[1] = {} while args[i] ~= nil and row == 0 do data[round][curr] = {} data[round][curr].e = data[round-1][prev].e data[round][curr].f = data[round-1][prev].f

if args[i] == "bye" then i = i + 1 elseif data[round-1][prev+1] ~= nil then local prev1 = data[round-1][prev].e local prev2 = data[round-1][prev].f local prev3 = data[round-1][prev+1].e local prev4 = data[round-1][prev+1].f local curr1 if prev2 > prev3 then curr1 = (prev2 + prev3 + (curr1 % 2)) / 2 else curr1 = (prev2 + prev3 - (curr1 % 2)) / 2 end local curr2 = (prev2 + prev3) - curr1 data[round][curr] = { a = prev1, b = prev2, c = prev3, d = prev4, e = curr1, f = curr2, args[i], args[i+1], args[i+2], args[i+3] } i = i + 4 end

prev = prev + 1 row = row + data[round][curr].e + data[round][curr].f if row == nTeam then round = round + 1 curr = 1 prev = 1 row = 0 data[round] = {} else curr = curr + 1 end end round = round - 1 local nRound = round

while round > 0 do row = 0 prev = 1 for curr = 1, #data[round] do data[round][curr].z = data[round][curr].z or round if data[round][curr].a == nil then data[round][prev].z = data[round][curr].z prev = prev + 1



else if data[round][curr][2] == ">" then data[round][curr].x = data[round][curr].z data[round][curr].y = round - 1 elseif data[round][curr][2] == "<" then data[round][curr].x = round - 1 data[round][curr].y = data[round][curr].z else data[round][curr].x = round - 1 data[round][curr].y = round - 1 end data[round][prev].z = data[round][curr].x data[round][prev+1].z = data[round][curr].y prev = prev + 2 end round = round - 1 end end

for round = 1, nRound do


end return "" end

return p