Skip to content

Commit

Permalink
Player turn aura (#171)
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Bastin <[email protected]>
  • Loading branch information
Trys2Hard and danbastin authored Mar 6, 2025
1 parent 1798ce6 commit 7ef8ebb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/app/GameBoard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const GameBoard = () => {
const [sidebarOpen, setSidebarOpen] = useState(sidebarState);
const [isPreferenceOpen, setPreferenceOpen] = useState(false);


useEffect(() => {
if(lobbyState && !lobbyState.gameOngoing && lobbyState.gameType !== MatchType.Quick) {
router.push('/lobby');
Expand Down Expand Up @@ -113,7 +112,7 @@ const GameBoard = () => {
<PlayerCardTray
trayPlayer={connectedPlayer}
toggleSidebar={toggleSidebar}
/>
/>
</Box>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const OpponentCardTray: React.FC<IOpponentCardTrayProps> = ({ trayPlayer, prefer

const hasInitiative = gameState.players[connectedPlayer].hasInitiative;
const initiativeClaimed = gameState.initiativeClaimed;
const activePlayer = gameState.players[connectedPlayer].isActionPhaseActivePlayer;
const phase = gameState.phase;

// ---------------Styles------------------- //
const styles = {
Expand All @@ -45,6 +47,7 @@ const OpponentCardTray: React.FC<IOpponentCardTrayProps> = ({ trayPlayer, prefer
width: '100%',
height: '100%',
transform: 'translateY(-2rem)',
zIndex: '1',
},
rightColumn: {
display: 'flex',
Expand Down Expand Up @@ -105,6 +108,18 @@ const OpponentCardTray: React.FC<IOpponentCardTrayProps> = ({ trayPlayer, prefer
userSelect: 'none',
color: 'black',
}
},
opponentTurnAura: {
height: '100px',
width: '90%',
position: 'absolute',
top: '-100px',
boxShadow: activePlayer === false ? '0px 20px 35px var(--initiative-red)' : phase === 'regroup' || phase === 'setup' ? '0px 15px 35px rgba(216,174,24,255)' : 'none',
transition: 'box-shadow .5s',
borderRadius: '50%',
left: '0',
right: '0',
marginInline: 'auto',
}
};

Expand All @@ -116,6 +131,7 @@ const OpponentCardTray: React.FC<IOpponentCardTrayProps> = ({ trayPlayer, prefer
display: 'flex',
flexWrap: 'nowrap',
columnGap: '2rem', // 2rem gap between columns
position: 'relative'
}}
>
{/* Left column (fixed 360px) */}
Expand All @@ -137,6 +153,7 @@ const OpponentCardTray: React.FC<IOpponentCardTrayProps> = ({ trayPlayer, prefer
<Box sx={styles.opponentHandWrapper}>
<PlayerHand clickDisabled={true} cards={gameState?.players[getOpponent(connectedPlayer)].cardPiles['hand'] || []} />
</Box>
<Box sx={ styles.opponentTurnAura} />
</Grid>

{/* Right column (fixed 360px) */}
Expand Down
18 changes: 18 additions & 0 deletions src/app/_components/Gameboard/PlayerCardTray/PlayerCardTray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { useGame } from '@/app/_contexts/Game.context';
const PlayerCardTray: React.FC<IPlayerCardTrayProps> = ({ trayPlayer, toggleSidebar }) => {
const { gameState, connectedPlayer } = useGame();

const activePlayer = gameState.players[connectedPlayer].isActionPhaseActivePlayer;
const phase = gameState.phase;

const styles = {
leftColumnStyle: {
display: 'flex',
Expand All @@ -38,13 +41,26 @@ const PlayerCardTray: React.FC<IPlayerCardTrayProps> = ({ trayPlayer, toggleSide
display: 'flex',
alignItems: 'flex-end',
transform: 'translateY(1.6rem)',
zIndex: '1',
},
chatColumn: {
display: 'flex',
alignItems: 'center',
height: '5.5rem',
margin: '0',
},
playerTurnAura: {
height: '100px',
width: '90%',
position: 'absolute',
bottom: '-120px',
boxShadow: activePlayer === true ? '0px -20px 35px var(--initiative-blue)' : phase === 'regroup' || phase === 'setup' ? '0px -15px 35px rgba(216,174,24,255)' : 'none',
transition: 'box-shadow .5s',
borderRadius: '50%',
left: '0',
right: '0',
marginInline: 'auto',
}
};

return (
Expand All @@ -55,6 +71,7 @@ const PlayerCardTray: React.FC<IPlayerCardTrayProps> = ({ trayPlayer, toggleSide
display: 'flex',
flexWrap: 'nowrap',
columnGap: '2rem', // 2rem gap between columns
position: 'relative'
}}
className="playerCardTrayWrapper"
>
Expand All @@ -81,6 +98,7 @@ const PlayerCardTray: React.FC<IPlayerCardTrayProps> = ({ trayPlayer, toggleSide
cards={gameState?.players[connectedPlayer].cardPiles['hand'] || []}
/>
</Box>
<Box sx={styles.playerTurnAura} />
</Grid>

{/* Right column: fixed 360px width */}
Expand Down

0 comments on commit 7ef8ebb

Please sign in to comment.