Example #1
0
 function prepareLB()
 {
     $x = 0;
     for ($i = 0.5; $i <= TourneyTree::numLBRounds($this->size) / 2;) {
         $res = $this->db->qry(sprintf($this->st, $i * -1));
         while ($row = $this->db->fetch_array($res)) {
             $this->lb_teams[$x][] = !$row['name'] ? array('name' => NULL, 'score' => 0) : $row;
         }
         $x++;
         $i = $i + 0.5;
     }
     // little fix coz lansuite saves overall-final to WB but we exspect it to be in LB
     $fix = array_pop($this->wb_teams);
     array_push($this->lb_teams, $fix);
     $fix = array_pop($this->wb_teams);
     array_push($this->wb_teams, $fix, $fix);
     foreach ($this->lb_teams as $round => $teams) {
         for ($i = 0; $i < count($teams); $i++) {
             $t1 = $this->lb_teams[$round][$i];
             $i++;
             $t2 = $this->lb_teams[$round][$i];
             if (!$t1['name']) {
                 $this->lb_teams[$round][$i - 1]['iswinner'] = 2;
                 $this->lb_teams[$round][$i]['iswinner'] = 1;
             } elseif (!$t2['name']) {
                 $this->lb_teams[$round][$i]['iswinner'] = 1;
                 $this->lb_teams[$round][$i - 1]['iswinner'] = 2;
             } elseif ($t1['score'] > $t2['score']) {
                 $this->lb_teams[$round][$i - 1]['iswinner'] = 1;
                 $this->lb_teams[$round][$i]['iswinner'] = 0;
             } elseif ($t1['score'] < $t2['score']) {
                 $this->lb_teams[$round][$i - 1]['iswinner'] = 0;
                 $this->lb_teams[$round][$i]['iswinner'] = 1;
             }
             if (!$t1['name'] && !$t2['name']) {
                 $this->lb_teams[$round][$i - 1]['iswinner'] = 2;
                 $this->lb_teams[$round][$i]['iswinner'] = 2;
             }
         }
     }
 }
Example #2
0
 function generateFakeTeams(&$wb, &$lb)
 {
     $wb = $lb = array();
     $sz = TourneyTree::log2($this->size);
     for ($i = 0; $i < $sz; $i++) {
         $wb[$i] = array();
         $x = TourneyTree::WBTeamsInRound($i + 1, $this->size);
         for ($j = 1; $j <= $x; $j++) {
             array_push($wb[$i], $j);
         }
     }
     array_push($wb, array('1'));
     for ($i = 0; $i < 2 * $sz - 2; $i++) {
         $lb[$i] = array();
         $x = TourneyTree::LBTeamsInRound($i + 1, $this->size);
         for ($j = 1; $j <= $x; $j++) {
             array_push($lb[$i], $j);
         }
     }
     array_push($lb, array('1'));
     return true;
 }