From b403174d101c02562f794ead5fb4cfa7bb9409c0 Mon Sep 17 00:00:00 2001 From: Cheelax Date: Tue, 19 Nov 2024 21:19:45 +0100 Subject: [PATCH] no highlight when moving --- client/src/ui/components/Tutorial/TutorialGrid.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/ui/components/Tutorial/TutorialGrid.tsx b/client/src/ui/components/Tutorial/TutorialGrid.tsx index 510972a..862c2f0 100644 --- a/client/src/ui/components/Tutorial/TutorialGrid.tsx +++ b/client/src/ui/components/Tutorial/TutorialGrid.tsx @@ -90,6 +90,7 @@ const TutorialGrid: React.FC = forwardRef( finalX: number; } | null>(null); const [blockBonus, setBlockBonus] = useState(null); + const [actionPerformed, setActionPerformed] = useState(false); useEffect(() => { if (gridRef.current) { @@ -180,6 +181,7 @@ const TutorialGrid: React.FC = forwardRef( }, [gameState]); const handleDragStart = (x: number, block: Block) => { + setActionPerformed(true); console.log("Drag start:", block); setDragging(block); setDragStartX(x); @@ -258,6 +260,7 @@ const TutorialGrid: React.FC = forwardRef( }, [dragging, initialX]); const handleBonusApplication = (block: Block) => { + setActionPerformed(true); setBlockBonus(block); if (bonus === BonusType.Wave) { setBlocks(removeBlocksSameRow(block, blocks)); @@ -397,8 +400,8 @@ const TutorialGrid: React.FC = forwardRef( }; const isHighlighted = (block: Block) => { - if (!tutorialTargetBlock) return false; - if (intermission) return false; + if (!tutorialTargetBlock || actionPerformed) return false; + if (tutorialTargetBlock.type === "row") { return block.y === tutorialTargetBlock.y; } else { @@ -508,6 +511,10 @@ const TutorialGrid: React.FC = forwardRef( } }, [gameState, blockBonus, selectBlock]); + useEffect(() => { + setActionPerformed(false); + }, [tutorialStep]); + return ( <>