diff --git a/backend/src/utils.ts b/backend/src/utils.ts index ad0e618..69e0b38 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -14,4 +14,4 @@ export function catchError(fn: ControllerFunction): ControllerFunction { res.status(500).json({ error: (error as Error).message }); } }; -} +} \ No newline at end of file diff --git a/frontend/src/library/Player.tsx b/frontend/src/library/Player.tsx new file mode 100644 index 0000000..f4d4146 --- /dev/null +++ b/frontend/src/library/Player.tsx @@ -0,0 +1,48 @@ +import React from 'react'; + +interface Player { + name: string; + cards: { length: number }; +} + +interface PlayerProps { + player: Player; + highlighted: boolean; + positionStyle: React.CSSProperties; +} + +const Player: React.FC = ({ + player, + highlighted, + positionStyle, +}) => { + return ( +
+
+ {player.cards.length} +
+
+ {player.name} +
+
+ ); +}; + +export default Player; diff --git a/frontend/src/pages/Game.tsx b/frontend/src/pages/Game.tsx index 4555fae..287e837 100644 --- a/frontend/src/pages/Game.tsx +++ b/frontend/src/pages/Game.tsx @@ -11,6 +11,7 @@ import { useNavigate } from 'react-router-dom'; import { triggerEvent } from '../channel'; import { useAuth } from '../contexts/AuthContext'; import { useToast } from '../library/toast/toast-context'; +import Player from '../library/Player'; function getCardImageName(card: UNOCard): string { function getColorAbbreviation(color: CardColor): string { @@ -173,10 +174,6 @@ function Game() { { top: '75%', left: '85%', transform: 'translate(-50%, -50%)' }, ]; - const cardStyles = { - filter: 'brightness(1)', - }; - if (!gameState) { return (
@@ -199,26 +196,12 @@ function Game() {
{/* Players */} {gameState.players.slice(0, 6).map((player, index) => ( -
-
- {player.cards.length} -
-
+ player={player} + highlighted={index === gameState.currentPlayerIndex} + positionStyle={playerPositions[index]} + /> ))} {/* Center Deck and UNO Button */}