Skip to content

Commit

Permalink
fix logic for determining a completed game
Browse files Browse the repository at this point in the history
  • Loading branch information
silentDjay committed Mar 26, 2024
1 parent 847d368 commit 8bf9dff
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/components/PlayGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,22 @@ export const PlayGame: React.FC = () => {
}

if (countryCode === targetCountryData?.cca2) {
addCountryToLocalStorageList(
targetCountryData.cca2,
gameCategory as GameCategory
);
setGameplayOverlayActive(true);
setClickStatus("CORRECT");
setGameStatus("SUCCESS");
captureEvent("WIN", {
...clickEventData,
countedClicks: getNumberOfClicksOnLand(clicks) + 1,
overallClicks: clicks.length + 1,
clickedFeature: countryName,
gameCompleted:
getCountriesFoundList(clickEventData.gameCategory as GameCategory)
.length === 1,
getFilteredCountryList(clickEventData.gameCategory as GameCategory)
.length === 0,
});
setGameplayOverlayActive(true);
setClickStatus("CORRECT");
setGameStatus("SUCCESS");
setClicks((currentClicks) => [
...currentClicks,
{
Expand All @@ -212,10 +216,6 @@ export const PlayGame: React.FC = () => {
winner: true,
},
]);
addCountryToLocalStorageList(
targetCountryData.cca2,
gameCategory as GameCategory
);
return;
}

Expand Down

0 comments on commit 8bf9dff

Please sign in to comment.