Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

PHP
$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];
Posted
Updated 28-Jun-14 19:45pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900