diff --git a/src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx b/src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx index 43a45b4..508849e 100644 --- a/src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx +++ b/src/app/_components/Lobby/_subcomponents/SetUpCard/SetUpCard.tsx @@ -91,13 +91,27 @@ const SetUpCard: React.FC = ({ 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); @@ -110,6 +124,7 @@ const SetUpCard: React.FC = ({ setDisplayerror(true); setDeckErrorSummary('Couldn\'t import. Deck is invalid.'); setDeckErrorDetails(temporaryErrors); + setErrorModalOpen(true); } }, [connectedUser]); diff --git a/src/app/_components/_sharedcomponents/Chat/Chat.tsx b/src/app/_components/_sharedcomponents/Chat/Chat.tsx index bdaab2f..a3fa083 100644 --- a/src/app/_components/_sharedcomponents/Chat/Chat.tsx +++ b/src/app/_components/_sharedcomponents/Chat/Chat.tsx @@ -24,28 +24,33 @@ const Chat: React.FC = ({ // 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 ( - - {message.alert.message.join('')} - - ) - } else if (message[0].type === 'playerChat') { + try { + if (message.hasOwnProperty('alert')) { + return ( + + {message.alert.message.join('')} + + ) + } else if (message[0].type === 'playerChat') { + return ( + + + {message[0].name} + : + {message.slice(1).join('')} + + ) + } + const stringMessage = message.map((item: IChatObject | string) => typeof item === 'object' ? item?.name : item).join(''); return ( - - {message[0].name} - : - {message.slice(1).join('')} + {stringMessage} ) + } 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 ( - - {stringMessage} - - ) } useEffect(() => { diff --git a/src/app/_contexts/Game.context.tsx b/src/app/_contexts/Game.context.tsx index 1866caf..d23e6da 100644 --- a/src/app/_contexts/Game.context.tsx +++ b/src/app/_contexts/Game.context.tsx @@ -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, });