diff --git a/apps/multiplayer/src/multiplayer.ts b/apps/multiplayer/src/multiplayer.ts index 95417b65..7d4a2156 100644 --- a/apps/multiplayer/src/multiplayer.ts +++ b/apps/multiplayer/src/multiplayer.ts @@ -358,11 +358,19 @@ export class Multiplayer implements DurableObject { ); if (allPlayersGuessedCorrectly) { - game.gameState.hasWon = true; - game.gameState.isActive = false; - game.gameState.statusMessage = { - type: 'success', - message: `Everyone guessed correctly! The word was "${game.gameState.targetWord}"`, + game.gameState = { + ...game.gameState, + hasWon: true, + isActive: false, + isLobby: true, + targetWord: '', + timeRemaining: this.GAME_DURATION, + currentDrawer: undefined, + endTime: undefined, + statusMessage: { + type: 'success', + message: `Everyone guessed correctly! The word was "${game.gameState.targetWord}"`, + }, }; if (game.timerInterval) { @@ -480,10 +488,19 @@ export class Multiplayer implements DurableObject { game.gameState.endTime && Date.now() >= game.gameState.endTime ) { - game.gameState.isActive = false; - game.gameState.statusMessage = { - type: 'failure', - message: `Time's up! The word was "${game.gameState.targetWord}"`, + const oldWord = game.gameState.targetWord; + game.gameState = { + ...game.gameState, + isActive: false, + isLobby: true, + targetWord: '', + timeRemaining: this.GAME_DURATION, + currentDrawer: undefined, + endTime: undefined, + statusMessage: { + type: 'failure', + message: `Time's up! The word was "${oldWord}"`, + }, }; if (game.timerInterval) { @@ -493,19 +510,12 @@ export class Multiplayer implements DurableObject { this.broadcast(gameId, { type: 'gameEnded', - gameState: { - ...game.gameState, - drawingData: undefined, - }, + gameState: game.gameState, users: Array.from(game.users.entries()).map(([id, data]) => ({ id, ...data, })), }); - - if (game.users.size === 0) { - this.games.delete(gameId); - } } } diff --git a/apps/web/components/DrawingCanvas/Components/Canvas.tsx b/apps/web/components/DrawingCanvas/Components/Canvas.tsx index 21f25562..c86405e8 100644 --- a/apps/web/components/DrawingCanvas/Components/Canvas.tsx +++ b/apps/web/components/DrawingCanvas/Components/Canvas.tsx @@ -152,9 +152,10 @@ export function Canvas({ ref={canvasRef} width={800} height={650} - className={`bg-[#f9fafb] top-0 left-0 w-full h-full max-h-[650px] border border-gray-200 rounded-lg touch-none ${ + className={`bg-[#f9fafb] w-full h-auto max-h-[80vh] border border-gray-200 rounded-lg touch-none ${ isReadOnly ? 'cursor-default' : 'cursor-crosshair' }`} + style={{ aspectRatio: '800 / 650' }} onMouseDown={startDrawing} onMouseUp={stopDrawing} onMouseOut={stopDrawing} diff --git a/apps/web/components/DrawingCanvas/Components/ColorPicker.tsx b/apps/web/components/DrawingCanvas/Components/ColorPicker.tsx index 402ccc1a..af2c9520 100644 --- a/apps/web/components/DrawingCanvas/Components/ColorPicker.tsx +++ b/apps/web/components/DrawingCanvas/Components/ColorPicker.tsx @@ -21,7 +21,7 @@ export function ColorPicker({ /> Custom Color -
+
{COLORS.map((color) => ( @@ -159,7 +160,7 @@ export function GameStatus({
)} -
+
+
+ ); + return ( -
-
+
+
{!result && ( -
+
{displaySidebar && ( -
-
-
- - - - - - - - -
+
+
)} -
+
+ {displaySidebar && ( +
+ + + + + + + Drawing Tools + + + + +
+ )} +
-
+
{!gameState.isActive && ( , + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +SheetOverlay.displayName = SheetPrimitive.Overlay.displayName + +const sheetVariants = cva( + "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", + { + variants: { + side: { + top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top", + bottom: + "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom", + left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm", + right: + "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm", + }, + }, + defaultVariants: { + side: "right", + }, + } +) + +interface SheetContentProps + extends React.ComponentPropsWithoutRef, + VariantProps {} + +const SheetContent = React.forwardRef< + React.ElementRef, + SheetContentProps +>(({ side = "right", className, children, ...props }, ref) => ( + + + + {children} + + + Close + + + +)) +SheetContent.displayName = SheetPrimitive.Content.displayName + +const SheetHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +SheetHeader.displayName = "SheetHeader" + +const SheetFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +SheetFooter.displayName = "SheetFooter" + +const SheetTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +SheetTitle.displayName = SheetPrimitive.Title.displayName + +const SheetDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +SheetDescription.displayName = SheetPrimitive.Description.displayName + +export { + Sheet, + SheetPortal, + SheetOverlay, + SheetTrigger, + SheetClose, + SheetContent, + SheetHeader, + SheetFooter, + SheetTitle, + SheetDescription, +}