From 593d3542fdc7e7ddbbe463b918fd0887a3fa7aa2 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 26 Feb 2021 10:23:51 +0100 Subject: [PATCH] Update Games class. Closes #1160 --- Blacklight/Games.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Blacklight/Games.php b/Blacklight/Games.php index 71a856dc7..304b1665a 100755 --- a/Blacklight/Games.php +++ b/Blacklight/Games.php @@ -509,9 +509,11 @@ class Games $result = $this->giantBomb->search($gameInfo['title'], 'Game'); if (! \is_object($result)) { + $percentCurrent = 0; foreach ($result as $res) { similar_text(strtolower($gameInfo['title']), strtolower($res->name), $percent1); - if ($percent1 >= self::GAME_MATCH_PERCENTAGE) { + if ($percent1 >= self::GAME_MATCH_PERCENTAGE && $percent1 > $percentCurrent) { + $percentCurrent = $percent1; $bestMatch = $res->id; } } @@ -576,9 +578,11 @@ class Games $this->_classUsed = 'IGDB'; $result = Game::where('name', $gameInfo['title'])->get(); if (! empty($result)) { + $percentCurrent = 0; foreach ($result as $res) { - similar_text(strtolower($gameInfo['title']), strtolower($res->name), $percent); - if ($percent >= self::GAME_MATCH_PERCENTAGE) { + similar_text(strtolower($gameInfo['title']), strtolower($res->name), $percent1); + if ($percent1 >= self::GAME_MATCH_PERCENTAGE && $percent1 > $percentCurrent) { + $percentCurrent = $percent1; $bestMatch = $res->id; } }