Skip to content

Commit

Permalink
fix: allow to start new game once completed
Browse files Browse the repository at this point in the history
The n key did not work after the game is complete. This is why...

Why does AI make these obvious problems?
  • Loading branch information
Lewiscowles1986 authored Sep 14, 2024
1 parent dbd10f4 commit 9a274e3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions components/klondike-solitaire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ export function KlondikeSolitaireComponent() {
};

const handleKeyPress = (e: React.KeyboardEvent) => {
if (gameWon) return;
const keyPressed = e.key.toLowerCase();
if (gameWon && keyPressed != 'n') return;

switch (e.key.toLowerCase()) {
switch (keyPressed) {
case 'd':
drawCards();
break;
Expand Down Expand Up @@ -255,4 +256,4 @@ export function KlondikeSolitaireComponent() {
</CardContent>
</CardGame>
);
}
}

0 comments on commit 9a274e3

Please sign in to comment.