Skip to content

Commit

Permalink
no highlight when moving
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheelax committed Nov 19, 2024
1 parent fc9f687 commit b403174
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/src/ui/components/Tutorial/TutorialGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const TutorialGrid: React.FC<GridProps> = forwardRef(
finalX: number;
} | null>(null);
const [blockBonus, setBlockBonus] = useState<Block | null>(null);
const [actionPerformed, setActionPerformed] = useState(false);

useEffect(() => {
if (gridRef.current) {
Expand Down Expand Up @@ -180,6 +181,7 @@ const TutorialGrid: React.FC<GridProps> = forwardRef(
}, [gameState]);

const handleDragStart = (x: number, block: Block) => {
setActionPerformed(true);
console.log("Drag start:", block);
setDragging(block);
setDragStartX(x);
Expand Down Expand Up @@ -258,6 +260,7 @@ const TutorialGrid: React.FC<GridProps> = forwardRef(
}, [dragging, initialX]);

const handleBonusApplication = (block: Block) => {
setActionPerformed(true);
setBlockBonus(block);
if (bonus === BonusType.Wave) {
setBlocks(removeBlocksSameRow(block, blocks));
Expand Down Expand Up @@ -397,8 +400,8 @@ const TutorialGrid: React.FC<GridProps> = 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 {
Expand Down Expand Up @@ -508,6 +511,10 @@ const TutorialGrid: React.FC<GridProps> = forwardRef(
}
}, [gameState, blockBonus, selectBlock]);

useEffect(() => {
setActionPerformed(false);
}, [tutorialStep]);

return (
<>
<ConfettiExplosion
Expand Down

0 comments on commit b403174

Please sign in to comment.