refactor: consolidate game components and add toast notifications

- Remove EndlosGame support and GameDetail141.jsx component
- Add Toast notification system with CSS styling
- Refactor GameCompletionModal with enhanced styling
- Improve GameDetail component structure and styling
- Add BaseLayout.astro for consistent page structure
- Update gameService with cleaner logic
- Enhance global styles and remove unused constants
- Streamline navigation components
This commit is contained in:
Frank Schwenk
2025-10-28 16:30:39 +01:00
parent d1e1616faa
commit 8bbe3b9b70
15 changed files with 532 additions and 433 deletions

View File

@@ -6,7 +6,7 @@ import { useNavigation, useNewGameWizard } from '../hooks/useNavigation';
import { useModal, useValidationModal, useCompletionModal } from '../hooks/useModal';
import { GameService } from '../services/gameService';
import type { StandardGame, EndlosGame } from '../types/game';
import type { StandardGame } from '../types/game';
import { Layout } from './ui/Layout';
import GameListScreen from './screens/GameListScreen';
@@ -36,42 +36,31 @@ export default function App() {
navigation.showGameDetail(gameId);
};
const handleUpdateScore = (player: number, change: number) => {
if (!navigation.currentGameId) return;
const game = gameState.getGameById(navigation.currentGameId);
if (!game || game.status === 'completed' || 'players' in game) return;
if (!game || game.status === 'completed') return;
const updatedGame = GameService.updateGameScore(game as StandardGame, player, change);
gameState.updateGame(navigation.currentGameId, updatedGame);
// Check for completion
if (GameService.isGameCompleted(updatedGame)) {
completionModal.openCompletionModal(updatedGame);
}
};
const handleGameAction = (updatedGame: EndlosGame) => {
if (!navigation.currentGameId) return;
const originalGame = gameState.getGameById(navigation.currentGameId);
if (!originalGame) return;
// Add undo state
// Add undo state for standard games
const gameWithHistory = {
...updatedGame,
undoStack: [...(originalGame.undoStack || []), originalGame],
undoStack: [...(game.undoStack || []), game],
updatedAt: new Date().toISOString(),
};
gameState.updateGame(navigation.currentGameId, gameWithHistory);
// Check for completion
if (GameService.isGameCompleted(gameWithHistory)) {
completionModal.openCompletionModal(gameWithHistory);
}
};
const handleUndo = () => {
if (!navigation.currentGameId) return;
@@ -181,10 +170,10 @@ export default function App() {
onFilterChange={gameState.setFilter}
onShowGameDetail={navigation.showGameDetail}
onDeleteGame={handleDeleteGame}
onShowNewGame={() => {
newGameWizard.startWizard();
navigation.showNewGame();
}}
onShowNewGame={() => {
newGameWizard.startWizard();
navigation.showNewGame();
}}
/>
)}
@@ -209,9 +198,7 @@ export default function App() {
game={gameState.getGameById(navigation.currentGameId)}
onUpdateScore={handleUpdateScore}
onFinishGame={handleFinishGame}
onUpdateGame={handleGameAction}
onUndo={handleUndo}
onForfeit={handleForfeit}
onBack={navigation.showGameList}
/>
)}