PHP脚本中的锦标赛支架种子 [英] tournament bracket seeding in php script

查看:99
本文介绍了PHP脚本中的锦标赛支架种子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编辑一个用PHP构建的工作CMS,并使用已实施的锦标赛支持系统。

我在确定如何从种子队列表中更改第一轮比赛时遇到问题。



如果代码给我的话,它已经有一个数组

1v8 4v5 2v7 3v6(8的括号中)。

我想要做的就是把它变回基本,改变代码让它给我

1v2 3v4 5v6 7v8等......

因此可以更容易制作手动括号,我的管理员可以操纵比赛中每个团队或玩家的位置。



我是一个设计师和我真的很糟糕的PHP代码,所以请帮助我。谢谢你,抱歉我的英文不好。



我正在研究的CMS有点过时,没有任何支持,名称是自治局域网,

代码中我想改变种子的部分,我发现它非常混乱:



I am editing a working CMS built in php with implemented tournament bracket system.
I have problems with figuring out how to change the first round matches from a list of seeded teams.

It allready has an array if code which gives me
1v8 4v5 2v7 3v6 ( in a bracket of 8 ).
What I want to do is turn it back to "basic", to change the code so it would give me
1v2 3v4 5v6 7v8 and so...
so it could be easier to make manual brackets, where my admin could manipulate the position of every team or player in tournament.

I am a designer and I am really bad with php code, so please help me. Thank you and sorry for my bad english.

CMS which I am working on is a bit outdated and doesnt have any support, the name is "autonomous LAN party",
The part of the code with seeds that I want to change, which I find really messy:

$seeding = array();
  for($j=4;$j<$n;$j*=2) {
  $temp = array();
  for($i=0;$i<sizeof($seeding);$i++) {
      if($seeding[$i]%2==0) {
          $temp[2*$i+1] = $seeding[$i];
          $temp[2*$i] = 0;
      } else {
          $temp[2*$i] = $seeding[$i];
          $temp[2*$i+1] = 0;
      }
  }
  for($i=0;$i<sizeof($temp);$i++) {
      if($temp[$i]==0) {
          if($i%8==1) $temp[$i] = (2*$j)+1 - $temp[$i-1]; // ||$i%8==3
          elseif($i%8==2||$i%8==6) $temp[$i] = $temp[$i-2] + (2*$j)/2;
          elseif($i%8==5) $temp[$i] = (2*$j)+1 - $temp[$i-1]; // ||$i%8==7

          //elseif($i%8==0) $temp[$i] = $temp[$i-8] + (2*$j)/8;
          //elseif($i%8==4) $temp[$i] = $temp[$i-2] - (2*$j)/4;
      }
  }
  $seeding = $temp;
  }

  $nums = array();
  for($i=0;$i<floor(sizeof($seeding)/4);$i++) {
  $nums[$i] = 0;
  }
      for($i=0;$i<sizeof($seeding);$i++) {
  if($seeding[$i]<=$n) $nums[floor($i/4)]++;
   }
  $completed = array();
  $up = true;
  for($i=0;$i<floor(sizeof($seeding)/4);$i++) {
  $completed[] = array($nums[$i],$up);
  $up = !$up;
    }

  $matchid = 0;
     for($i=$rounds;$i>0;$i--) {
  $teamsperround = pow(2,$rounds-$i);

  $multiplier = $NHPT/$teamsperround;
  $top = true;
  $servercounter = 0;
  $matchcounter = 1;
  for ($j=1; $j <= $teamsperround; $j++) {
      if ($i == 2) {
          $type = $completed[floor(($j-1)/2)][0];
          $up = $completed[floor(($j-1)/2)][1];
          if ($type == 2 || ($type==3 && (($j%2==1 && $up) ||      ($j%2==0&&!$up)))) {
              if ($seeding[($j-1)*2] > $seeding[($j-1)*2+1]) {
                  $holder = $teams[$seeding[($j-1)*2+1]-1];
              } else {
                  $holder = $teams[$seeding[($j-1)*2]-1];
              }
          } else {
              $holder = '';
          }
      } elseif ($i == 1) {
          $type = $completed[floor(($j-1)/4)][0];
          $up = $completed[floor(($j-1)/4)][1];
          if ($tournament['ffa']&&$tournament['rrsplit']>0) $holder = $teams[$ffaseeding[$j-1+$extra[$i-1]*($matchcounter-1)]-1];
          else $holder = $teams[$seeding[$j-1]-1];

推荐答案

播种 = array();
for(
seeding = array(); for(


j = 4;


j<


这篇关于PHP脚本中的锦标赛支架种子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆