@@ -93,9 +93,13 @@ discard block |
||
| 93 | 93 | return $this->games; |
| 94 | 94 | } |
| 95 | 95 | public function isPlayed(){ |
| 96 | - if (count($this->games) === 0) return false; |
|
| 96 | + if (count($this->games) === 0) { |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 97 | 99 | foreach ($this->groups as $group) { |
| 98 | - if (!$group->isPlayed()) return false; |
|
| 100 | + if (!$group->isPlayed()) { |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 99 | 103 | } |
| 100 | 104 | return true; |
| 101 | 105 | } |
@@ -131,14 +135,18 @@ discard block |
||
| 131 | 135 | |
| 132 | 136 | public function splitTeams(Group ...$groups) { |
| 133 | 137 | |
| 134 | - if (count($groups) === 0) $groups = $this->getGroups(); |
|
| 138 | + if (count($groups) === 0) { |
|
| 139 | + $groups = $this->getGroups(); |
|
| 140 | + } |
|
| 135 | 141 | |
| 136 | 142 | $teams = $this->getTeams(); |
| 137 | 143 | shuffle($teams); |
| 138 | 144 | |
| 139 | 145 | while (count($teams) > 0) { |
| 140 | 146 | foreach ($groups as $group) { |
| 141 | - if (count($teams) > 0) $group->addTeam(array_shift($teams)); |
|
| 147 | + if (count($teams) > 0) { |
|
| 148 | + $group->addTeam(array_shift($teams)); |
|
| 149 | + } |
|
| 142 | 150 | } |
| 143 | 151 | } |
| 144 | 152 | return $this; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | private $allowSkip = false; |
| 22 | 22 | |
| 23 | - function __construct(string $name = ''){ |
|
| 23 | + function __construct(string $name = '') { |
|
| 24 | 24 | $this->name = $name; |
| 25 | 25 | } |
| 26 | 26 | public function __toString() { |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | public function getCategoryWait() { |
| 64 | 64 | return $this->expectedCategoryWait; |
| 65 | 65 | } |
| 66 | - public function getTournamentTime(){ |
|
| 66 | + public function getTournamentTime() { |
|
| 67 | 67 | $games = count($this->getGames()); |
| 68 | 68 | return $games*$this->expectedPlay+$games*$this->expectedGameWait+count($this->getRounds())*$this->expectedRoundWait+count($this->getCategories())*$this->expectedCategoryWait; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function allowSkip(){ |
|
| 71 | + public function allowSkip() { |
|
| 72 | 72 | $this->allowSkip = true; |
| 73 | 73 | return $this; |
| 74 | 74 | } |
| 75 | - public function disallowSkip(){ |
|
| 75 | + public function disallowSkip() { |
|
| 76 | 76 | $this->allowSkip = false; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return $this->allowSkip; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function addCategory(Category ...$categories){ |
|
| 87 | + public function addCategory(Category ...$categories) { |
|
| 88 | 88 | foreach ($categories as $category) { |
| 89 | 89 | $this->categories[] = $category; |
| 90 | 90 | } |
@@ -141,7 +141,9 @@ discard block |
||
| 141 | 141 | $teams = array_merge($teams, $round->getTeams()); |
| 142 | 142 | } |
| 143 | 143 | $this->teams = \array_unique($teams); |
| 144 | - if ($ordered) $this->sortTeams($ordering); |
|
| 144 | + if ($ordered) { |
|
| 145 | + $this->sortTeams($ordering); |
|
| 146 | + } |
|
| 145 | 147 | return $this->teams; |
| 146 | 148 | } |
| 147 | 149 | public function sortTeams($ordering = \TournamentGenerator\Constants::POINTS) { |
@@ -164,14 +166,18 @@ discard block |
||
| 164 | 166 | |
| 165 | 167 | public function splitTeams(Round ...$wheres) { |
| 166 | 168 | |
| 167 | - if (count($wheres) === 0) $wheres = $this->getRounds(); |
|
| 169 | + if (count($wheres) === 0) { |
|
| 170 | + $wheres = $this->getRounds(); |
|
| 171 | + } |
|
| 168 | 172 | |
| 169 | 173 | $teams = $this->getTeams(); |
| 170 | 174 | shuffle($teams); |
| 171 | 175 | |
| 172 | 176 | while (count($teams) > 0) { |
| 173 | 177 | foreach ($wheres as $where) { |
| 174 | - if (count($teams) > 0) $where->addTeam(array_shift($teams)); |
|
| 178 | + if (count($teams) > 0) { |
|
| 179 | + $where->addTeam(array_shift($teams)); |
|
| 180 | + } |
|
| 175 | 181 | } |
| 176 | 182 | } |
| 177 | 183 | foreach ($wheres as $where) { |
@@ -183,13 +189,17 @@ discard block |
||
| 183 | 189 | public function genGamesSimulate(bool $returnTime = false) { |
| 184 | 190 | $games = Utilis\Simulator::simulateTournament($this); |
| 185 | 191 | |
| 186 | - if ($returnTime) return $this->getTournamentTime(); |
|
| 192 | + if ($returnTime) { |
|
| 193 | + return $this->getTournamentTime(); |
|
| 194 | + } |
|
| 187 | 195 | return $games; |
| 188 | 196 | } |
| 189 | 197 | public function genGamesSimulateReal(bool $returnTime = false) { |
| 190 | 198 | $games = Utilis\Simulator::simulateTournamentReal($this); |
| 191 | 199 | |
| 192 | - if ($returnTime) return $this->getTournamentTime(); |
|
| 200 | + if ($returnTime) { |
|
| 201 | + return $this->getTournamentTime(); |
|
| 202 | + } |
|
| 193 | 203 | return $games; |
| 194 | 204 | } |
| 195 | 205 | |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | return $this->id; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function allowSkip(){ |
|
| 53 | + public function allowSkip() { |
|
| 54 | 54 | $this->generator->allowSkip(); |
| 55 | 55 | return $this; |
| 56 | 56 | } |
| 57 | - public function disallowSkip(){ |
|
| 57 | + public function disallowSkip() { |
|
| 58 | 58 | $this->generator->disallowSkip(); |
| 59 | 59 | return $this; |
| 60 | 60 | } |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | public function addProgressed(...$teams) { |
| 164 | - $this->progressed = array_merge($this->progressed, array_filter($teams, function($a){return $a instanceof Team;})); |
|
| 165 | - foreach (array_filter($teams, function($a){return is_array($a);}) as $team) { |
|
| 164 | + $this->progressed = array_merge($this->progressed, array_filter($teams, function($a) {return $a instanceof Team; })); |
|
| 165 | + foreach (array_filter($teams, function($a) {return is_array($a); }) as $team) { |
|
| 166 | 166 | $this->progressed = array_merge($this->progressed, array_filter($team, function($a) { |
| 167 | 167 | return ($a instanceof Team); |
| 168 | 168 | })); |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | $this->games[] = $g; |
| 184 | 184 | return $g; |
| 185 | 185 | } |
| 186 | - public function addGame(...$games){ |
|
| 187 | - $this->games = array_merge($this->games, array_filter($games, function($a){ return ($a instanceof Game); })); |
|
| 186 | + public function addGame(...$games) { |
|
| 187 | + $this->games = array_merge($this->games, array_filter($games, function($a) { return ($a instanceof Game); })); |
|
| 188 | 188 | |
| 189 | - foreach (array_filter($games, function($a){return is_array($a);}) as $key => $game) { |
|
| 190 | - $this->games = array_merge($this->games, array_filter($game, function($a){ return ($a instanceof Game); })); |
|
| 189 | + foreach (array_filter($games, function($a) {return is_array($a); }) as $key => $game) { |
|
| 190 | + $this->games = array_merge($this->games, array_filter($game, function($a) { return ($a instanceof Game); })); |
|
| 191 | 191 | } |
| 192 | 192 | return $this; |
| 193 | 193 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | return $this; |
| 211 | 211 | } |
| 212 | - public function isPlayed(){ |
|
| 212 | + public function isPlayed() { |
|
| 213 | 213 | if (count($this->games) === 0) return false; |
| 214 | 214 | foreach ($this->games as $game) { |
| 215 | 215 | if (!$game->isPlayed()) return false; |
@@ -100,7 +100,9 @@ discard block |
||
| 100 | 100 | return $t; |
| 101 | 101 | } |
| 102 | 102 | public function sortTeams(array $filters = [], $ordering = null) { |
| 103 | - if (!isset($ordering)) $ordering = $this->ordering; |
|
| 103 | + if (!isset($ordering)) { |
|
| 104 | + $ordering = $this->ordering; |
|
| 105 | + } |
|
| 104 | 106 | Utilis\Sorter\Teams::sortGroup($this->teams, $this, $ordering); |
| 105 | 107 | return $this->getTeams($filters); |
| 106 | 108 | } |
@@ -130,7 +132,9 @@ discard block |
||
| 130 | 132 | } |
| 131 | 133 | |
| 132 | 134 | public function setOrdering(string $ordering = \TournamentGenerator\Constants::POINTS) { |
| 133 | - if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown group ordering: '.$ordering); |
|
| 135 | + if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) { |
|
| 136 | + throw new \Exception('Unknown group ordering: '.$ordering); |
|
| 137 | + } |
|
| 134 | 138 | $this->ordering = $ordering; |
| 135 | 139 | return $this; |
| 136 | 140 | } |
@@ -195,7 +199,9 @@ discard block |
||
| 195 | 199 | return $this->games; |
| 196 | 200 | } |
| 197 | 201 | public function orderGames() { |
| 198 | - if (count($this->games) <= 4) return $this->games; |
|
| 202 | + if (count($this->games) <= 4) { |
|
| 203 | + return $this->games; |
|
| 204 | + } |
|
| 199 | 205 | $this->games = $this->generator->orderGames(); |
| 200 | 206 | return $this->games; |
| 201 | 207 | } |
@@ -210,9 +216,13 @@ discard block |
||
| 210 | 216 | return $this; |
| 211 | 217 | } |
| 212 | 218 | public function isPlayed(){ |
| 213 | - if (count($this->games) === 0) return false; |
|
| 219 | + if (count($this->games) === 0) { |
|
| 220 | + return false; |
|
| 221 | + } |
|
| 214 | 222 | foreach ($this->games as $game) { |
| 215 | - if (!$game->isPlayed()) return false; |
|
| 223 | + if (!$game->isPlayed()) { |
|
| 224 | + return false; |
|
| 225 | + } |
|
| 216 | 226 | } |
| 217 | 227 | return true; |
| 218 | 228 | } |