Implement Specials feature, Admin UI enhancements, and Database Rebuild tool

This commit is contained in:
Hördle Bot
2025-11-22 16:09:45 +01:00
parent c270f2098f
commit 903d626699
16 changed files with 816 additions and 37 deletions

View File

@@ -17,12 +17,14 @@ interface GameProps {
coverImage: string | null;
} | null;
genre?: string | null;
maxAttempts?: number;
unlockSteps?: number[];
}
const UNLOCK_STEPS = [2, 4, 7, 11, 16, 30, 60];
const DEFAULT_UNLOCK_STEPS = [2, 4, 7, 11, 16, 30, 60];
export default function Game({ dailyPuzzle, genre = null }: GameProps) {
const { gameState, statistics, addGuess } = useGameState(genre);
export default function Game({ dailyPuzzle, genre = null, maxAttempts = 7, unlockSteps = DEFAULT_UNLOCK_STEPS }: GameProps) {
const { gameState, statistics, addGuess } = useGameState(genre, maxAttempts);
const [hasWon, setHasWon] = useState(false);
const [hasLost, setHasLost] = useState(false);
const [shareText, setShareText] = useState('Share Result');
@@ -54,13 +56,13 @@ export default function Game({ dailyPuzzle, genre = null }: GameProps) {
if (song.id === dailyPuzzle.songId) {
addGuess(song.title, true);
setHasWon(true);
sendGotifyNotification(gameState.guesses.length + 1, 'won', dailyPuzzle.id);
sendGotifyNotification(gameState.guesses.length + 1, 'won', dailyPuzzle.id, genre);
} else {
addGuess(song.title, false);
if (gameState.guesses.length + 1 >= 7) {
if (gameState.guesses.length + 1 >= maxAttempts) {
setHasLost(true);
setHasWon(false); // Ensure won is false
sendGotifyNotification(7, 'lost', dailyPuzzle.id);
sendGotifyNotification(maxAttempts, 'lost', dailyPuzzle.id, genre);
}
}
};
@@ -75,14 +77,14 @@ export default function Game({ dailyPuzzle, genre = null }: GameProps) {
addGuess("SKIPPED", false);
setHasLost(true);
setHasWon(false);
sendGotifyNotification(7, 'lost', dailyPuzzle.id);
sendGotifyNotification(maxAttempts, 'lost', dailyPuzzle.id, genre);
};
const unlockedSeconds = UNLOCK_STEPS[Math.min(gameState.guesses.length, 6)];
const unlockedSeconds = unlockSteps[Math.min(gameState.guesses.length, unlockSteps.length - 1)];
const handleShare = () => {
let emojiGrid = '';
const totalGuesses = 7;
const totalGuesses = maxAttempts;
// Build the grid
for (let i = 0; i < totalGuesses; i++) {
@@ -135,7 +137,7 @@ export default function Game({ dailyPuzzle, genre = null }: GameProps) {
<div style={{ borderBottom: '1px solid #e5e7eb', paddingBottom: '1rem' }}>
<div className="status-bar">
<span>Attempt {gameState.guesses.length + 1} / 7</span>
<span>Attempt {gameState.guesses.length + 1} / {maxAttempts}</span>
<span>{unlockedSeconds}s unlocked</span>
</div>
<AudioPlayer
@@ -167,7 +169,7 @@ export default function Game({ dailyPuzzle, genre = null }: GameProps) {
onClick={handleSkip}
className="skip-button"
>
Skip (+{UNLOCK_STEPS[Math.min(gameState.guesses.length + 1, 6)] - unlockedSeconds}s)
Skip (+{unlockSteps[Math.min(gameState.guesses.length + 1, unlockSteps.length - 1)] - unlockedSeconds}s)
</button>
) : (
<button