Skip to content

Commit

Permalink
handling weird case
Browse files Browse the repository at this point in the history
  • Loading branch information
vuonghy2442 committed Apr 10, 2024
1 parent 7835d03 commit b4df7b9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,11 @@ function initGame() {
card.turnUp(REVEAL_TIME);
});

let handlingMove = false;

function moveCard(event, card) {
handlingMove = true;

const origin = game.find_origin(card);

let moving_cards = [card];
Expand Down Expand Up @@ -574,6 +578,7 @@ function initGame() {
moving_cards.forEach((c, idx) => c.moveTo(u * 100, v * 100 + idx * UP_SPACE, 0));
game.make_move(card, origin, snapped);
}
handlingMove = false;
}

window.addEventListener("pointermove", handlePointerMove);
Expand All @@ -588,7 +593,7 @@ function initGame() {
}

function onPointerDown(event) {
if (event.which !== 1 || !event.isPrimary) return;
if (event.which !== 1 || !event.isPrimary || handlingMove) return;

const cardDOM = event.target.closest(".card");

Expand Down

0 comments on commit b4df7b9

Please sign in to comment.