Fixing "Nesting level too deep" issue

This commit is contained in:
Jeroen De Meerleer 2019-11-10 09:37:13 +01:00
parent 3faa4be0bd
commit 6603b049a6
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 16 additions and 4 deletions

View File

@ -82,4 +82,19 @@ class Game
return $result; return $result;
} }
/**
* Checks if 2 games are equal
*
* @param Game $game1
* @param Game $game2
* @return bool
*/
public function equals(Game $game): bool
{
return (
$this->White->Player === $game->White->Player &&
$this->Black->Player === $game->Black->Player &&
$this->Result == $game->Result);
}
} }

View File

@ -311,10 +311,7 @@ class Tournament
return false; return false;
} }
foreach ($games as $roundgame) { foreach ($games as $roundgame) {
if ($roundgame->White == $game->White && if ($game->equals($roundgame)) {
$roundgame->Black == $game->Black &&
$roundgame->Result == $game->Result
) {
return true; return true;
} }
} }