diff --git a/src/components/BalancedTernaryGame.tsx b/src/components/BalancedTernaryGame.tsx index e105065..eb57c0b 100644 --- a/src/components/BalancedTernaryGame.tsx +++ b/src/components/BalancedTernaryGame.tsx @@ -51,9 +51,19 @@ const BalancedTernaryGame: React.FC = ({ showSocialSha setHasGameStarted(true); }, [targetRange]); - // Start game for the first time + // Start game for the first time or reset game const startGame = () => { - startNewGame(); + if (hasGameStarted) { + // Reset to allow range selection + setIsGameActive(false); + setHasGameStarted(false); + setIsGameWon(false); + setTimer(0); + setCurrentSum(0); + setCardValues(new Array(8).fill(0)); + } else { + startNewGame(); + } }; // Timer effect @@ -169,7 +179,7 @@ const BalancedTernaryGame: React.FC = ({ showSocialSha {/* Range Selection */} - {!hasGameStarted && ( + {!isGameActive && (
@@ -283,7 +293,7 @@ const BalancedTernaryGame: React.FC = ({ showSocialSha
)} - diff --git a/src/components/TernaryNumberGame.tsx b/src/components/TernaryNumberGame.tsx index cc339a4..e4c3f7d 100644 --- a/src/components/TernaryNumberGame.tsx +++ b/src/components/TernaryNumberGame.tsx @@ -46,9 +46,19 @@ const TernaryNumberGame: React.FC = ({ showSocialShare = setHasGameStarted(true); }, [targetRange]); - // Start game for the first time + // Start game for the first time or reset game const startGame = () => { - startNewGame(); + if (hasGameStarted) { + // Reset to allow range selection + setIsGameActive(false); + setHasGameStarted(false); + setIsGameWon(false); + setTimer(0); + setCurrentSum(0); + setCardValues(new Array(8).fill(0)); + } else { + startNewGame(); + } }; // Timer effect @@ -120,7 +130,7 @@ const TernaryNumberGame: React.FC = ({ showSocialShare = {/* Range Selection */} - {!hasGameStarted && ( + {!isGameActive && (
@@ -217,7 +227,7 @@ const TernaryNumberGame: React.FC = ({ showSocialShare =
)} -