experimental premove support (closes #7)
This commit is contained in:
@@ -218,12 +218,14 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isDraggablePiece({ piece }: { piece: string }) {
|
function isDraggablePiece({ piece }: { piece: string }) {
|
||||||
if (lobby.side === "s") return true;
|
|
||||||
return piece.startsWith(lobby.side);
|
return piece.startsWith(lobby.side);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDrop(sourceSquare: Square, targetSquare: Square) {
|
function onDrop(sourceSquare: Square, targetSquare: Square) {
|
||||||
if (lobby.side !== lobby.actualGame.turn()) return false;
|
if (lobby.side === "s") return false;
|
||||||
|
|
||||||
|
// premove
|
||||||
|
if (lobby.side !== lobby.actualGame.turn()) return true;
|
||||||
|
|
||||||
const moveDetails = {
|
const moveDetails = {
|
||||||
from: sourceSquare,
|
from: sourceSquare,
|
||||||
@@ -406,6 +408,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
|
|||||||
onPieceDrop={onDrop}
|
onPieceDrop={onDrop}
|
||||||
onSquareClick={onSquareClick}
|
onSquareClick={onSquareClick}
|
||||||
onSquareRightClick={onSquareRightClick}
|
onSquareRightClick={onSquareRightClick}
|
||||||
|
arePremovesAllowed={true}
|
||||||
customSquareStyles={{
|
customSquareStyles={{
|
||||||
...customSquares.lastMove,
|
...customSquares.lastMove,
|
||||||
...customSquares.check,
|
...customSquares.check,
|
||||||
|
|||||||
Reference in New Issue
Block a user