diff --git a/src/Game.php b/src/Game.php index bfa6ab4..e3c936c 100644 --- a/src/Game.php +++ b/src/Game.php @@ -82,4 +82,19 @@ class Game 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); + } } diff --git a/src/Tournament.php b/src/Tournament.php index 0055436..7d98c72 100644 --- a/src/Tournament.php +++ b/src/Tournament.php @@ -311,10 +311,7 @@ class Tournament return false; } foreach ($games as $roundgame) { - if ($roundgame->White == $game->White && - $roundgame->Black == $game->Black && - $roundgame->Result == $game->Result - ) { + if ($game->equals($roundgame)) { return true; } }