diff --git a/src/features/snake-game/SnakeGame.tsx b/src/features/snake-game/SnakeGame.tsx
index 71e8f75..9f93734 100644
--- a/src/features/snake-game/SnakeGame.tsx
+++ b/src/features/snake-game/SnakeGame.tsx
@@ -89,9 +89,12 @@ export function SnakeGame({ className = '' }: SnakeGameProps) {
status={status}
score={score}
mode={mode}
+ difficulty={difficulty}
leaderboard={leaderboard}
onStart={handleStartClick}
onSaveScore={actions.saveToLeaderboard}
+ onSetDifficulty={actions.setDifficulty}
+ onSetMode={actions.setMode}
/>
{status === 'countdown' && }
diff --git a/src/features/snake-game/components/GameOverlay.tsx b/src/features/snake-game/components/GameOverlay.tsx
index 0cc0bc8..61ddafd 100644
--- a/src/features/snake-game/components/GameOverlay.tsx
+++ b/src/features/snake-game/components/GameOverlay.tsx
@@ -1,25 +1,33 @@
import { memo, useState } from 'react';
-import type { GameStatus, GameMode, LeaderboardEntry } from '../types';
-import { DIFFICULTY_LABELS } from '../constants';
+import type { GameStatus, GameMode, LeaderboardEntry, Difficulty } from '../types';
+import { DIFFICULTY_LABELS, MODE_LABELS } from '../constants';
const MEDALS = ['#FFD700', '#C0C0C0', '#CD7F32'] as const;
+const DIFFICULTIES: Difficulty[] = ['easy', 'normal', 'hard'];
+const MODES: GameMode[] = ['casual', 'competitive'];
interface GameOverlayProps {
status: GameStatus;
score: number;
mode: GameMode;
+ difficulty: Difficulty;
leaderboard: LeaderboardEntry[];
onStart: () => void;
onSaveScore: (name: string) => void;
+ onSetDifficulty: (d: Difficulty) => void;
+ onSetMode: (m: GameMode) => void;
}
export const GameOverlay = memo(function GameOverlay({
status,
score,
mode,
+ difficulty,
leaderboard,
onStart,
onSaveScore,
+ onSetDifficulty,
+ onSetMode,
}: GameOverlayProps) {
const [playerName, setPlayerName] = useState('');
const [saved, setSaved] = useState(false);
@@ -43,6 +51,8 @@ export const GameOverlay = memo(function GameOverlay({
onStart();
};
+ const buttonLabel = status === 'victory' ? 'jogar novamente' : 'tentar novamente';
+
return (
@@ -134,12 +144,44 @@ export const GameOverlay = memo(function GameOverlay({
)}
-
+
+
+ {DIFFICULTIES.map((d) => (
+
+ ))}
+ |
+ {MODES.map((m) => (
+
+ ))}
+
+
+
+
);
diff --git a/src/features/snake-game/store/useGameStore.ts b/src/features/snake-game/store/useGameStore.ts
index d3717f3..7cc8f7f 100644
--- a/src/features/snake-game/store/useGameStore.ts
+++ b/src/features/snake-game/store/useGameStore.ts
@@ -122,13 +122,13 @@ export const useGameStore = create((set, get) => ({
setDifficulty: (difficulty: Difficulty) => {
const { status } = get();
- if (status !== 'idle') return;
+ if (status === 'playing' || status === 'paused' || status === 'countdown') return;
set({ difficulty });
},
setMode: (mode: GameMode) => {
const { status } = get();
- if (status !== 'idle') return;
+ if (status === 'playing' || status === 'paused' || status === 'countdown') return;
set({ mode });
},