Skip to content

Commit

Permalink
Board layout 182025 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
danbastin authored Jan 9, 2025
1 parent 2714513 commit db6a538
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 63 deletions.
4 changes: 2 additions & 2 deletions src/app/GameBoard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const GameBoard = () => {
},
centralPromptContainer: {
position: 'absolute',
top: '50%',
top: '47%',
left: '50%',
transform: 'translate(-50%, -50%)',
display: 'flex',
Expand All @@ -86,7 +86,7 @@ const GameBoard = () => {
}

return (
<Grid container sx={{ height: '100vh' }}>
<Grid container sx={{ height: '100vh', overflow: 'hidden' }}>
<Box component="main" sx={styles.mainBoxStyle}>
<OpponentCardTray trayPlayer={getOpponent(connectedPlayer)} />
<Board sidebarOpen={sidebarOpen} />
Expand Down
3 changes: 2 additions & 1 deletion src/app/_components/Gameboard/Board/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import UnitsBoard from '../_subcomponents/UnitsBoard';
import { IBoardProps } from '@/app/_components/Gameboard/GameboardTypes';
import { useGame } from '@/app/_contexts/Game.context';
import LeaderBaseCard from '@/app/_components/_sharedcomponents/Cards/LeaderBaseCard/LeaderBaseCard';
import { Box, Typography } from '@mui/material';
import { Box } from '@mui/material';

const Board: React.FC<IBoardProps> = ({
sidebarOpen,
Expand Down Expand Up @@ -56,6 +56,7 @@ const Board: React.FC<IBoardProps> = ({
flexDirection: 'column',
alignItems: 'center',
width: '100%',
gap: '10px',
},
rowStyle: {
flexGrow: 1,
Expand Down
32 changes: 17 additions & 15 deletions src/app/_components/Gameboard/OpponentCardTray/OpponentCardTray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@ const OpponentCardTray: React.FC<IOpponentCardTrayProps> = ({ trayPlayer }) => {
const styles = {
leftColumn: {
display: 'flex',
alignItems: 'flex-start',
alignItems: 'center',
justifyContent: 'flex-start',
pl: '2em',
pt: '2em',
gap: '10px',
pl: '1em',
},
centerColumn: {
height: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
alignItems: 'flex-start',
justifyContent: 'center',
},
opponentHandWrapper: {
width: '100%',
height: '100%',
transform: 'translateY(-30%)',
},
rightColumn: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
pr: '2em',
gap: '15px',
pr: '1em',
py: '1em',
},
lastPlayed: {
Expand All @@ -57,20 +63,16 @@ const OpponentCardTray: React.FC<IOpponentCardTrayProps> = ({ trayPlayer }) => {
<Grid container sx={{ height: '15%' }}>
<Grid size={3} sx={styles.leftColumn}>
<DeckDiscard trayPlayer={trayPlayer} />
<Box ml={1}>
<Resources
trayPlayer={trayPlayer}
/>
</Box>
<Resources trayPlayer={trayPlayer}/>
</Grid>
<Grid size={6} sx={styles.centerColumn}>
<PlayerHand cards={gameState?.players[getOpponent(connectedPlayer)].cardPiles['hand'] || []} />
<Box sx={styles.opponentHandWrapper}>
<PlayerHand cards={gameState?.players[getOpponent(connectedPlayer)].cardPiles['hand'] || []} />
</Box>
</Grid>
<Grid size={3} sx={styles.rightColumn}>
<Box mr={2}>
<Typography variant={'h4'}>Initiative</Typography>
</Box>
<Box sx={styles.lastPlayed} mr={2}>
<Typography variant={'h4'}>Initiative</Typography>
<Box sx={styles.lastPlayed}>
</Box>
<Box sx={styles.menuStyles}>
<CloseOutlined onClick={handleExitButton} sx={{ cursor:'pointer' }}/>
Expand Down
70 changes: 40 additions & 30 deletions src/app/_components/Gameboard/PlayerCardTray/PlayerCardTray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CardActionTray from '../_subcomponents/PlayerTray/CardActionTray';
import PlayerHand from '../_subcomponents/PlayerTray/PlayerHand';
import { IPlayerCardTrayProps } from '@/app/_components/Gameboard/GameboardTypes';
import { useGame } from '@/app/_contexts/Game.context';
import { display } from '@mui/system';

const PlayerCardTray: React.FC<IPlayerCardTrayProps> = ({
trayPlayer,
Expand All @@ -17,43 +18,52 @@ const PlayerCardTray: React.FC<IPlayerCardTrayProps> = ({
const { gameState, connectedPlayer } = useGame();

// ---------------Styles------------------- //
const leftColumnStyle = {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-start',
padding: '1em',
};

const centerColumnStyle = {
height: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
};

const rightColumnStyle = {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
padding: '1em',
};
const styles = {
leftColumnStyle: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-start',
padding: '1em',
gap: '10px',
},
centerColumnStyle: {
height: '100%',
},
rightColumnStyle: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
padding: '1em',
},
playerHandWrapper: {
width: '100%',
height: '100%',
transform: 'translateY(15%)',
transition: 'transform 0.4s ease',
display : 'flex',
alignItems : 'center',
'&:hover': {
transform: 'translateY(0)',
},
},
}

return (
<Grid container sx={{ height: '20.82%' }}>
<Grid size={3} sx={leftColumnStyle}>
<Grid size={3} sx={styles.leftColumnStyle}>
<DeckDiscard trayPlayer={trayPlayer} />
<Box ml={1}>
<Resources
trayPlayer={trayPlayer}
handleModalToggle={handleModalToggle}
/>
</Box>
<Resources
trayPlayer={trayPlayer}
handleModalToggle={handleModalToggle}
/>
</Grid>
<Grid size={6} sx={centerColumnStyle}>
<PlayerHand cards={gameState?.players[connectedPlayer].cardPiles['hand'] || []} />
<Grid size={6} sx={styles.centerColumnStyle}>
<Box sx={styles.playerHandWrapper}>
<PlayerHand cards={gameState?.players[connectedPlayer].cardPiles['hand'] || []} />
</Box>
</Grid>
<Grid size={3} sx={rightColumnStyle}>
<Grid size={3} sx={styles.rightColumnStyle}>
<CardActionTray />
<Box ml={2}>
<ChatBubbleOutline />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const CardActionTray: React.FC = () => {
spacing={2}
sx={actionContainerStyle}
>
<Box>
<Box sx={{ display: 'flex', gap: '10px' }}>
{playerState.promptState.buttons.map((button: IButtonsProps) => (
<PromptButton
key={button.arg}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const PlayerHand: React.FC<IPlayerHandProps> = ({
width: '100%',
overflowX: 'auto',
whiteSpace: 'nowrap',
p: '10px 0',
cursor: isDragging ? 'grabbing' : 'grab',
userSelect: 'none',
scrollbarWidth: 'thin',
Expand Down
17 changes: 7 additions & 10 deletions src/app/_components/Gameboard/_subcomponents/UnitsBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,25 @@ const UnitsBoard: React.FC<IUnitsBoardProps> = ({
height: '100%',
width: '100%',
padding: '1em',
margin: '1em',
},
containerStyle: {
height: '100%',
},
opponentGridStyle: {
flexGrow: 1,
height: '50%',
display: 'flex',
justifyContent: arena == 'groundArena' ? 'flex-start': 'flex-end',
alignItems: 'flex-start',
gap: '0.5vw',
flexWrap: 'nowrap',
overflowX: 'auto',
gap: '10px',
flexWrap: 'wrap',
},
playerGridStyle: {
flexGrow: 1,
height: '50%',
display: 'flex',
justifyContent: arena == 'groundArena' ? 'flex-start': 'flex-end',
alignItems: 'flex-end',
gap: '0.5vw',
flexWrap: 'nowrap',
overflowX: 'auto',
gap: '10px',
flexWrap: 'wrap',
},
};

Expand All @@ -104,7 +101,7 @@ const UnitsBoard: React.FC<IUnitsBoardProps> = ({
{/* Player's Ground Units */}
<Grid sx={styles.playerGridStyle}>
{playerUnits.map((card: ICardData) => (
<Box key={card.uuid} sx={{ flex: '0 0 auto' }}>
<Box key={card.uuid} sx={{ flex: '0 1 auto' }}>
<GameCard card={card} subcards={card.subcards} size="square" variant={'gameboard'}/>
</Box>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ const GameCard: React.FC<IGameCardProps> = ({
) : variant === 'gameboard' ? (
<>
<Grid direction="row" container sx={styles.shieldContainerStyle}>
{shieldCards.map((shieldCard) => (
{shieldCards.map((_, index) => (
<>
<Box
key={shieldCard.uuid}
key={`${cardData.uuid}-shield-${index}`}
sx={styles.shieldIconLayer}
/>
</>
Expand Down
1 change: 0 additions & 1 deletion src/app/_utils/s3Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export const s3ImageURL = (path: string) => {

export const s3CardImageURL = (card: ICardData | ISetCode) => {
if (!card) return 'game/epic-action-token.webp';
console.log(card);
const cardNumber = card.setId.number.toString().padStart(3, '0') + (card.type === 'leaderUnit' ? '-portrait' : '');
return s3ImageURL(`cards/${card.setId.set}/${cardNumber}.webp`);
};
Expand Down

0 comments on commit db6a538

Please sign in to comment.