Skip to content

Commit

Permalink
Merge branch 'main' into player-turn-aura
Browse files Browse the repository at this point in the history
  • Loading branch information
danbastin authored Mar 6, 2025
2 parents fc029a3 + 1798ce6 commit bbd4fb9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
17 changes: 16 additions & 1 deletion src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,27 @@ const SetUpCard: React.FC<ISetUpProps> = ({

const temporaryErrors: IDeckValidationFailures = connectedUser.importDeckErrors;
// Determine if a blocking error exists (ignoring NotImplemented and temporary errors)
// we want two errors that won't trigger the

if (Object.keys(deckErrors).length > 0) {
// Show a short inline error message and store the full list
setDisplayerror(true);
setDeckErrorSummary('Deck is invalid.');
setDeckErrorDetails(deckErrors);
setBlockError(true)
setBlockError(true);

// Check if any errors other than the specified ones exist
const hasOtherErrors = Object.keys(deckErrors).some(key =>
key !== DeckValidationFailureReason.MinMainboardSizeNotMet &&
key !== DeckValidationFailureReason.MaxSideboardSizeExceeded
);

// Only open modal if there are validation errors besides the two excluded types
if (hasOtherErrors) {
setErrorModalOpen(true);
} else {
setErrorModalOpen(false);
}
}else{
setDeckErrorSummary(null);
setDeckErrorDetails(undefined);
Expand All @@ -110,6 +124,7 @@ const SetUpCard: React.FC<ISetUpProps> = ({
setDisplayerror(true);
setDeckErrorSummary('Couldn\'t import. Deck is invalid.');
setDeckErrorDetails(temporaryErrors);
setErrorModalOpen(true);
}
}, [connectedUser]);

Expand Down
39 changes: 22 additions & 17 deletions src/app/_components/_sharedcomponents/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,33 @@ const Chat: React.FC<IChatProps> = ({
// TODO: Standardize these chat types
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const formatMessage = (message: any, index: number) => {
if (message.hasOwnProperty('alert')) {
return (
<Typography key={index} sx={styles.alertText}>
{message.alert.message.join('')}
</Typography>
)
} else if (message[0].type === 'playerChat') {
try {
if (message.hasOwnProperty('alert')) {
return (
<Typography key={index} sx={styles.alertText}>
{message.alert.message.join('')}
</Typography>
)
} else if (message[0].type === 'playerChat') {
return (
<Typography key={index} sx={styles.messageText}>
<Typography component="span" sx={{ color: connectedPlayer === message[0].id ? 'var(--initiative-blue)' : 'var(--initiative-red)' }}>
{message[0].name}
</Typography>:
{message.slice(1).join('')}
</Typography>
)
}
const stringMessage = message.map((item: IChatObject | string) => typeof item === 'object' ? item?.name : item).join('');
return (
<Typography key={index} sx={styles.messageText}>
<Typography component="span" sx={{ color: connectedPlayer === message[0].id ? 'var(--initiative-blue)' : 'var(--initiative-red)' }}>
{message[0].name}
</Typography>:
{message.slice(1).join('')}
{stringMessage}
</Typography>
)
} catch (error) {
console.error('Error formatting message:', error);
return null;
}
const stringMessage = message.map((item: IChatObject | string) => typeof item === 'object' ? item?.name : item).join('');
return (
<Typography key={index} sx={styles.messageText}>
{stringMessage}
</Typography>
)
}

useEffect(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/_contexts/Game.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,20 @@ export const GameProvider = ({ children }: { children: ReactNode }) => {
switch (cardSelectionZones[0]) {
case 'resources':
openPopup('pile', {
uuid: `${connectedPlayer}-resources`,
uuid: `${connectedPlayerId}-resources`,
title: 'Your Resources',
subtitle: menuTitle,
cards: gameState?.players[connectedPlayer]?.cardPiles['resources'],
cards: gameState?.players[connectedPlayerId]?.cardPiles['resources'],
source: PopupSource.PromptState,
buttons: buttons,
});
break;
case 'discard':
openPopup('pile', {
uuid: `${connectedPlayer}-discard`,
uuid: `${connectedPlayerId}-discard`,
title: 'Your Discard',
subtitle: menuTitle,
cards: gameState?.players[connectedPlayer]?.cardPiles['discard'],
cards: gameState?.players[connectedPlayerId]?.cardPiles['discard'],
source: PopupSource.PromptState,
buttons: buttons,
});
Expand Down

0 comments on commit bbd4fb9

Please sign in to comment.