Skip to content

Commit

Permalink
Frontend: Dislay The Player Whose Turn It Is Currently
Browse files Browse the repository at this point in the history
1. Brightened player icons for active turn indication.

2. Displayed current player's name on game board.

Fixes: #157
  • Loading branch information
asmit27rai committed Jun 26, 2024
1 parent ab4243f commit 2e5ceaf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ export function AuthProvider({ children }: { children: ReactElement }) {
{children}
</AuthContext.Provider>
);
}
}
2 changes: 1 addition & 1 deletion frontend/src/contexts/GameContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ export const useGameContext = () => {
throw new Error('useGameContext must be used within a GameProvider');
}
return context;
};
};
2 changes: 1 addition & 1 deletion frontend/src/library/toast/toast-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export const ToastContext = createContext<ToastContextValue>({
close: () => {},
});

export const useToast = () => useContext(ToastContext);
export const useToast = () => useContext(ToastContext);
2 changes: 1 addition & 1 deletion frontend/src/library/toast/toast.css
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@
left: 0.5rem;
right: 0.5rem;
}
}
}
15 changes: 14 additions & 1 deletion frontend/src/pages/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ function Game() {
{ top: '75%', left: '15%', transform: 'translate(-50%, -50%)' },
{ top: '75%', left: '85%', transform: 'translate(-50%, -50%)' },
];

const cardStyles = {
filter: 'brightness(1)',
};

if (!gameState) {
return (
<div className="bg-gray-800 h-screen text-white text-5xl font-kavoon text-center">
Expand All @@ -190,18 +195,26 @@ function Game() {
return (
<div className="flex justify-center items-center min-h-screen bg-table-bg bg-cover">
<div className="relative w-full max-w-6xl h-[75vh]">
<div className="absolute top-4 left-1/2 transform -translate-x-1/2 text-yellow-400 text-xl font-bold">
{gameState.players[gameState.currentPlayerIndex].name}'s
Turn
</div>
{/* Players */}
{gameState.players.slice(0, 6).map((player, index) => (
<div
key={index}
className="absolute flex flex-col items-center justify-center bg-player-icon-bg"
className={`absolute flex flex-col items-center justify-center bg-player-icon-bg`}
style={{
...playerPositions[index],
backgroundSize: 'contain',
backgroundRepeat: 'no-repeat',
width: '70px',
height: '80px',
zIndex: 2,
...(index === gameState.currentPlayerIndex && {
...cardStyles,
filter: 'brightness(1.5)',
}),
}}
>
<div className="player-cards text-black mt-[61px]">
Expand Down

0 comments on commit 2e5ceaf

Please sign in to comment.