Skip to content

Commit

Permalink
Merge pull request #152 from Ido-Barnea/151-players-can-drag-enemy-pi…
Browse files Browse the repository at this point in the history
…eces

Fixed players being able to drag enemy pieces
  • Loading branch information
Ido-Barnea authored Jan 21, 2024
2 parents a836985 + c6fb640 commit 62cee4a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions development/code/ui/Events.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 62cee4a

Please sign in to comment.