@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | return $this->name; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function addGroup(Group ...$groups){ |
|
| 26 | + public function addGroup(Group ...$groups) { |
|
| 27 | 27 | foreach ($groups as $group) { |
| 28 | 28 | if ($group instanceof Group) $this->groups[] = $group; |
| 29 | 29 | else throw new \Exception('Trying to add group which is not an instance of Group class.'); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $this->groups[] = $g->setSkip($this->allowSkip); |
| 36 | 36 | return $g; |
| 37 | 37 | } |
| 38 | - public function getGroups(){ |
|
| 38 | + public function getGroups() { |
|
| 39 | 39 | $this->orderGroups(); |
| 40 | 40 | return $this->groups; |
| 41 | 41 | } |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | return array_map(function($a) { return $a->id; }, $this->groups); |
| 45 | 45 | } |
| 46 | 46 | public function orderGroups() { |
| 47 | - usort($this->groups, function($a, $b){ |
|
| 48 | - return $a->getOrder() - $b->getOrder(); |
|
| 47 | + usort($this->groups, function($a, $b) { |
|
| 48 | + return $a->getOrder()-$b->getOrder(); |
|
| 49 | 49 | }); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function allowSkip(){ |
|
| 52 | + public function allowSkip() { |
|
| 53 | 53 | $this->allowSkip = true; |
| 54 | 54 | return $this; |
| 55 | 55 | } |
| 56 | - public function disallowSkip(){ |
|
| 56 | + public function disallowSkip() { |
|
| 57 | 57 | $this->allowSkip = false; |
| 58 | 58 | return $this; |
| 59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | return $this->allowSkip; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function genGames(){ |
|
| 68 | + public function genGames() { |
|
| 69 | 69 | foreach ($this->groups as $group) { |
| 70 | 70 | $group->genGames(); |
| 71 | 71 | $this->games = array_merge($this->games, $group->orderGames()); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | public function getGames() { |
| 76 | 76 | return $this->games; |
| 77 | 77 | } |
| 78 | - public function isPlayed(){ |
|
| 78 | + public function isPlayed() { |
|
| 79 | 79 | foreach ($this->groups as $group) { |
| 80 | 80 | if (!$group->isPlayed()) return false; |
| 81 | 81 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public function addTeam(...$teams) { |
| 86 | 86 | foreach ($teams as $team) { |
| 87 | - if ($team instanceof Team) { |
|
| 87 | + if ($team instanceof Team) { |
|
| 88 | 88 | $this->teams[] = $team; |
| 89 | 89 | } |
| 90 | 90 | elseif (gettype($team) === 'array') { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function progress(bool $blank = false){ |
|
| 156 | + public function progress(bool $blank = false) { |
|
| 157 | 157 | foreach ($this->groups as $group) { |
| 158 | 158 | $group->progress($blank); |
| 159 | 159 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | $this->splitTeams($round1); |
| 32 | 32 | |
| 33 | - if (count($this->getTeams()) % 4 == 2) { |
|
| 33 | + if (count($this->getTeams())%4 == 2) { |
|
| 34 | 34 | $group_top = $round2->group('TOP')->setType(\TournamentGenerator\Constants::ROUND_TWO); |
| 35 | 35 | |
| 36 | 36 | $filter_win_2 = new \TournamentGenerator\TeamFilter('wins', '=', 2, [$group_0_0, $group_top]); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $groupIds = []; |
| 32 | 32 | $allGroups = []; |
| 33 | 33 | |
| 34 | - for ($i=1; $i <= $startGroups; $i++) { |
|
| 34 | + for ($i = 1; $i <= $startGroups; $i++) { |
|
| 35 | 35 | $g = $startRound->group('Start group - '.$i)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO); |
| 36 | 36 | $allGroups[] = $g; |
| 37 | 37 | $groupIds[] = $g->id; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | // SPLIT TEAMS EVENLY |
| 42 | 42 | $this->splitTeams(); |
| 43 | 43 | |
| 44 | - for ($r=2; $r <= $roundsNum-1; $r++) { |
|
| 44 | + for ($r = 2; $r <= $roundsNum-1; $r++) { |
|
| 45 | 45 | $groups = []; |
| 46 | 46 | $losingGroups = []; |
| 47 | 47 | $round = $this->round('Round '.$r); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | private function calcByes(int $countTeams, int &$nextPow) { |
| 76 | 76 | $byes = 0; |
| 77 | 77 | $nextPow = $countTeams; |
| 78 | - if ( !\TournamentGenerator\isPowerOf2($countTeams) ) { |
|
| 78 | + if (!\TournamentGenerator\isPowerOf2($countTeams)) { |
|
| 79 | 79 | $nextPow = bindec(str_pad(1, strlen(decbin($countTeams))+1, 0, STR_PAD_RIGHT)); |
| 80 | 80 | $byes = $nextPow-$countTeams; |
| 81 | 81 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | private function generateWinSide(int &$r, int &$byes, int &$countTeams, \TournamentGenerator\Round &$round, array &$allGroups, array &$groups, \TournamentGenerator\Group &$lastWinningGroup = null, array &$previousGroups = []) { |
| 85 | 85 | $order = 1; |
| 86 | - for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) { |
|
| 86 | + for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) { |
|
| 87 | 87 | $group = $round->group('Round '.$r.' - win '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO)->setOrder($order); |
| 88 | 88 | $allGroups[] = $group; |
| 89 | 89 | $order += 2; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $losingGroupTeamsCount = count($previousLosingGroups)+count($previousGroups); |
| 99 | 99 | $order = 2; |
| 100 | 100 | if (\TournamentGenerator\isPowerOf2($losingGroupTeamsCount)) { // IF THE NUMBER OF TEAMS IS A POWER OF 2, GENERATE GROUPS WITHOUT BYES |
| 101 | - for ($g=1; $g <= $losingGroupTeamsCount/2; $g++) { |
|
| 101 | + for ($g = 1; $g <= $losingGroupTeamsCount/2; $g++) { |
|
| 102 | 102 | $group = $round->group('Round '.$r.' - loss '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO)->setOrder($order); |
| 103 | 103 | $allGroups[] = $group; |
| 104 | 104 | $order += 2; |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | $n = (floor(count($previousLosingGroups)/2)+$losingByes); |
| 122 | 122 | $byesGroupsNums = []; |
| 123 | 123 | $byesProgressed = 0; |
| 124 | - for ($i=0; $i < $losingByes; $i++) { |
|
| 124 | + for ($i = 0; $i < $losingByes; $i++) { |
|
| 125 | 125 | $byesGroupsNums[] = $n-($i*2); |
| 126 | 126 | } |
| 127 | 127 | $lastGroup = 0; |
| 128 | - for ($g=1; $g <= ((count($previousLosingGroups)/2)+$losingByes); $g++) { |
|
| 128 | + for ($g = 1; $g <= ((count($previousLosingGroups)/2)+$losingByes); $g++) { |
|
| 129 | 129 | $group = $round->group('Round '.$r.' - loss '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO)->setOrder($order); |
| 130 | 130 | $allGroups[] = $group; |
| 131 | 131 | $order += 2; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | else { |
| 139 | 139 | $previousLosingGroups[$lastGroup]->progression($group, 0, 1); // PROGRESS FROM LOSING GROUP BEFORE |
| 140 | - if (isset($previousLosingGroups[$lastGroup + 1])) $previousLosingGroups[$lastGroup + 1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE |
|
| 140 | + if (isset($previousLosingGroups[$lastGroup+1])) $previousLosingGroups[$lastGroup+1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE |
|
| 141 | 141 | $lastGroup += 2; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | // CALCULATE BYES |
| 18 | 18 | $byes = 0; |
| 19 | - if ( !\TournamentGenerator\isPowerOf2($countTeams) ) { |
|
| 19 | + if (!\TournamentGenerator\isPowerOf2($countTeams)) { |
|
| 20 | 20 | $nextPow = bindec(str_pad(1, strlen(decbin($countTeams))+1, 0, STR_PAD_RIGHT)); |
| 21 | 21 | $byes = $nextPow-$countTeams; |
| 22 | 22 | } |
@@ -27,17 +27,17 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $previousGroups = []; |
| 29 | 29 | |
| 30 | - for ($i=1; $i <= (($countTeams+$byes)/2); $i++) { |
|
| 30 | + for ($i = 1; $i <= (($countTeams+$byes)/2); $i++) { |
|
| 31 | 31 | $g = $startRound->group('Round 1 '.$i)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO); |
| 32 | 32 | $previousGroups[] = $g; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $this->splitTeams(); |
| 36 | 36 | |
| 37 | - for ($r=2; $r <= $roundsNum; $r++) { |
|
| 37 | + for ($r = 2; $r <= $roundsNum; $r++) { |
|
| 38 | 38 | $groups = []; |
| 39 | 39 | $round = $this->round('Round '.$r); |
| 40 | - for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) { |
|
| 40 | + for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) { |
|
| 41 | 41 | $group = $round->group('Round '.$r.' - '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO); |
| 42 | 42 | $groups[] = $group; |
| 43 | 43 | array_shift($previousGroups)->progression($group, 0, 1); // PROGRESS FROM GROUP BEFORE |