Skip to content

Commit

Permalink
fix build of chess js and versioning to latest stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-zheng-codes committed Dec 9, 2024
1 parent af1a779 commit 215ba99
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions components/ChessBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use client';

import { useState } from "react";
import Chess from "chess.js";

// import Chess from 'chess.js';
import { Chess, ShortMove, Square } from 'chess.js';
import { Chessboard } from "react-chessboard";


export default function ChessBoardRandom() {
const [game, setGame] = useState(new Chess());

function makeAMove(move) {
function makeAMove(move: string | ShortMove) {
const gameCopy = { ...game };
const result = gameCopy.move(move);
setGame(gameCopy);
Expand All @@ -22,7 +25,7 @@ export default function ChessBoardRandom() {
makeAMove(possibleMoves[randomIndex]);
}

function onDrop(sourceSquare, targetSquare) {
function onDrop(sourceSquare: Square, targetSquare: Square) {
const move = makeAMove({
from: sourceSquare,
to: targetSquare,
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@radix-ui/react-slot": "^1.1.0",
"chess.js": "^0.12.0",
"chess.js": "^0.13.4",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^0.468.0",
Expand Down

0 comments on commit 215ba99

Please sign in to comment.