diff --git a/development/code/ui/Events.ts b/development/code/ui/Events.ts index 82cc73bc..cf0594d2 100644 --- a/development/code/ui/Events.ts +++ b/development/code/ui/Events.ts @@ -1,3 +1,4 @@ +import { game } from '../Game'; import { onPieceSelected } from '../LogicAdapter'; import { HEAVEN_BOARD_BUTTON_ID, HELL_BOARD_BUTTON_ID, OVERWORLD_BOARD_BUTTON_ID } from '../logic/Constants'; import { HEAVEN_BOARD, HELL_BOARD, OVERWORLD_BOARD } from './BoardManager'; @@ -52,6 +53,9 @@ export function dragPieceElement(element: HTMLElement) { function dragPieceOnMouseDown(event: MouseEvent) { event.preventDefault(); + const currentTurnPlayerColor = game.getCurrentPlayer().color.toLowerCase(); + if (!element.classList.contains(currentTurnPlayerColor)) return; + endMouseX = event.clientX; endMouseY = event.clientY; document.onmousemove = pieceElementDrag;