@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | $game->setResults($results); |
19 | 19 | } |
20 | 20 | $return = $group->sortTeams(null, $filters); |
21 | - if (!$reset) return $return; |
|
21 | + if (!$reset) { |
|
22 | + return $return; |
|
23 | + } |
|
22 | 24 | foreach ($group->getGames() as $game) { |
23 | 25 | $game->resetResults(); |
24 | 26 | } |
@@ -27,14 +29,18 @@ discard block |
||
27 | 29 | |
28 | 30 | public static function simulateRound(\TournamentGenerator\Round $round) { |
29 | 31 | foreach ($round->getGroups() as $group) { |
30 | - if ($group->isPlayed()) continue; |
|
32 | + if ($group->isPlayed()) { |
|
33 | + continue; |
|
34 | + } |
|
31 | 35 | $group->simulate([], false); |
32 | 36 | } |
33 | 37 | return true; |
34 | 38 | } |
35 | 39 | |
36 | 40 | public static function simulateTournament(\TournamentGenerator\Tournament $tournament) { |
37 | - if (count($tournament->getCategories()) === 0 && count($tournament->getRounds()) === 0) throw new \Exception('There are no rounds or categories to simulate games from.'); |
|
41 | + if (count($tournament->getCategories()) === 0 && count($tournament->getRounds()) === 0) { |
|
42 | + throw new \Exception('There are no rounds or categories to simulate games from.'); |
|
43 | + } |
|
38 | 44 | |
39 | 45 | $games = []; |
40 | 46 | |
@@ -51,7 +57,9 @@ discard block |
||
51 | 57 | |
52 | 58 | public static function simulateTournamentReal(\TournamentGenerator\Tournament $tournament) { |
53 | 59 | $games = []; |
54 | - if (count($tournament->getCategories()) === 0 && count($tournament->getRounds()) === 0) throw new \Exception('There are no rounds or categories to simulate games from.'); |
|
60 | + if (count($tournament->getCategories()) === 0 && count($tournament->getRounds()) === 0) { |
|
61 | + throw new \Exception('There are no rounds or categories to simulate games from.'); |
|
62 | + } |
|
55 | 63 | |
56 | 64 | foreach ($tournament->getRounds() as $round) { |
57 | 65 | $games = array_merge($games, $round->genGames()); |
@@ -62,7 +70,9 @@ discard block |
||
62 | 70 | } |
63 | 71 | |
64 | 72 | public static function simulateCategory(\TournamentGenerator\Category $category) { |
65 | - if (count($category->getRounds()) === 0) throw new \Exception('There are no rounds to simulate games from.'); |
|
73 | + if (count($category->getRounds()) === 0) { |
|
74 | + throw new \Exception('There are no rounds to simulate games from.'); |
|
75 | + } |
|
66 | 76 | |
67 | 77 | $games = []; |
68 | 78 | |
@@ -79,7 +89,9 @@ discard block |
||
79 | 89 | |
80 | 90 | public static function simulateCategoryReal(\TournamentGenerator\Category $category) { |
81 | 91 | $games = []; |
82 | - if (count($category->getRounds()) === 0) throw new \Exception('There are no rounds to simulate games from.'); |
|
92 | + if (count($category->getRounds()) === 0) { |
|
93 | + throw new \Exception('There are no rounds to simulate games from.'); |
|
94 | + } |
|
83 | 95 | |
84 | 96 | foreach ($category->getRounds() as $round) { |
85 | 97 | $games = array_merge($games, $round->genGames()); |
@@ -73,7 +73,9 @@ discard block |
||
73 | 73 | } |
74 | 74 | $teams = \array_unique($teams); |
75 | 75 | $this->teams = $teams; |
76 | - if ($ordered) $teams = $this->sortTeams($ordering); |
|
76 | + if ($ordered) { |
|
77 | + $teams = $this->sortTeams($ordering); |
|
78 | + } |
|
77 | 79 | |
78 | 80 | // APPLY FILTERS |
79 | 81 | $filter = new Filter($this->getGroups(), $filters); |
@@ -106,14 +108,18 @@ discard block |
||
106 | 108 | |
107 | 109 | public function splitTeams(Round ...$wheres) { |
108 | 110 | |
109 | - if (count($wheres) === 0) $wheres = $this->getRounds(); |
|
111 | + if (count($wheres) === 0) { |
|
112 | + $wheres = $this->getRounds(); |
|
113 | + } |
|
110 | 114 | |
111 | 115 | $teams = $this->getTeams(); |
112 | 116 | shuffle($teams); |
113 | 117 | |
114 | 118 | while (count($teams) > 0) { |
115 | 119 | foreach ($wheres as $where) { |
116 | - if (count($teams) > 0) $where->addTeam(array_shift($teams)); |
|
120 | + if (count($teams) > 0) { |
|
121 | + $where->addTeam(array_shift($teams)); |
|
122 | + } |
|
117 | 123 | } |
118 | 124 | } |
119 | 125 | foreach ($wheres as $where) { |
@@ -64,7 +64,9 @@ discard block |
||
64 | 64 | public function getTeams(bool $ordered = false, $ordering = \TournamentGenerator\Constants::POINTS, array $filters = []) { |
65 | 65 | $teams = $this->teams; |
66 | 66 | |
67 | - if ($ordered) return $this->sortTeams($ordering, $filters); |
|
67 | + if ($ordered) { |
|
68 | + return $this->sortTeams($ordering, $filters); |
|
69 | + } |
|
68 | 70 | |
69 | 71 | // APPLY FILTERS |
70 | 72 | $filter = new Filter([$this], $filters); |
@@ -79,7 +81,9 @@ discard block |
||
79 | 81 | return $t; |
80 | 82 | } |
81 | 83 | public function sortTeams($ordering = null, array $filters = []) { |
82 | - if (!isset($ordering)) $ordering = $this->ordering; |
|
84 | + if (!isset($ordering)) { |
|
85 | + $ordering = $this->ordering; |
|
86 | + } |
|
83 | 87 | $this->teams = Utilis\Sorter\Teams::sortGroup($this->teams, $this, $ordering); |
84 | 88 | return $this->getTeams(false, null, $filters); |
85 | 89 | } |
@@ -109,7 +113,9 @@ discard block |
||
109 | 113 | } |
110 | 114 | |
111 | 115 | public function setOrdering(string $ordering = \TournamentGenerator\Constants::POINTS) { |
112 | - if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown group ordering: '.$ordering); |
|
116 | + if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) { |
|
117 | + throw new \Exception('Unknown group ordering: '.$ordering); |
|
118 | + } |
|
113 | 119 | $this->ordering = $ordering; |
114 | 120 | return $this; |
115 | 121 | } |
@@ -174,7 +180,9 @@ discard block |
||
174 | 180 | return $this->games; |
175 | 181 | } |
176 | 182 | public function orderGames() { |
177 | - if (count($this->games) <= 4) return $this->games; |
|
183 | + if (count($this->games) <= 4) { |
|
184 | + return $this->games; |
|
185 | + } |
|
178 | 186 | $this->games = $this->generator->orderGames(); |
179 | 187 | return $this->games; |
180 | 188 | } |
@@ -189,9 +197,13 @@ discard block |
||
189 | 197 | return $this; |
190 | 198 | } |
191 | 199 | public function isPlayed(){ |
192 | - if (count($this->games) === 0) return false; |
|
200 | + if (count($this->games) === 0) { |
|
201 | + return false; |
|
202 | + } |
|
193 | 203 | foreach ($this->games as $game) { |
194 | - if (!$game->isPlayed()) return false; |
|
204 | + if (!$game->isPlayed()) { |
|
205 | + return false; |
|
206 | + } |
|
195 | 207 | } |
196 | 208 | return true; |
197 | 209 | } |