fix : lint warnings & errors

This commit is contained in:
GuillaumeSD
2024-02-25 02:19:13 +01:00
parent 8d15b7e1a2
commit 7412f708d0
6 changed files with 18 additions and 21 deletions

View File

@@ -56,7 +56,7 @@ export const useCurrentMove = (engineName?: EngineName) => {
}
setCurrentMove(move);
}, [gameEval, board, game, engine, depth, multiPv]);
}, [gameEval, board, game, engine, depth, multiPv, setCurrentMove]);
return currentMove;
};

View File

@@ -1,20 +1,10 @@
import { Stockfish16 } from "@/lib/engine/stockfish16";
import { UciEngine } from "@/lib/engine/uciEngine";
import { engineMultiPvAtom } from "@/sections/analysis/states";
import { EngineName } from "@/types/enums";
import { useAtomValue } from "jotai";
import { useEffect, useState } from "react";
export const useEngine = (engineName: EngineName | undefined) => {
const [engine, setEngine] = useState<UciEngine | null>(null);
const multiPv = useAtomValue(engineMultiPvAtom);
const pickEngine = (engine: EngineName): UciEngine => {
switch (engine) {
case EngineName.Stockfish16:
return new Stockfish16(multiPv);
}
};
useEffect(() => {
if (!engineName) return;
@@ -27,7 +17,14 @@ export const useEngine = (engineName: EngineName | undefined) => {
return () => {
engine.shutdown();
};
}, []);
}, [engineName]);
return engine;
};
const pickEngine = (engine: EngineName): UciEngine => {
switch (engine) {
case EngineName.Stockfish16:
return new Stockfish16();
}
};

View File

@@ -2,14 +2,14 @@ import { EngineName } from "@/types/enums";
import { UciEngine } from "./uciEngine";
export class Stockfish16 extends UciEngine {
constructor(multiPv: number) {
constructor() {
const isWasmSupported = Stockfish16.isWasmSupported();
const enginePath = isWasmSupported
? "engines/stockfish-wasm/stockfish-nnue-16-single.js"
: "engines/stockfish.js";
super(EngineName.Stockfish16, enginePath, multiPv);
super(EngineName.Stockfish16, enginePath);
}
public static isWasmSupported() {

View File

@@ -10,12 +10,10 @@ export abstract class UciEngine {
private worker: Worker;
private ready = false;
private engineName: EngineName;
private multiPv: number;
private multiPv = 3;
constructor(engineName: EngineName, enginePath: string, multiPv: number) {
constructor(engineName: EngineName, enginePath: string) {
this.engineName = engineName;
this.multiPv = multiPv;
this.worker = new Worker(enginePath);
console.log(`${engineName} created`);

View File

@@ -32,7 +32,7 @@ export default function GameReport() {
setBoardOrientation(true);
gameActions.setPgn(new Chess().pgn());
}
}, [gameId]);
}, [gameId, boardActions, gameActions, setEval, setBoardOrientation]);
return (
<Grid

View File

@@ -17,13 +17,15 @@ export default function EvaluationBar({ height }: Props) {
const boardOrientation = useAtomValue(boardOrientationAtom);
const currentMove = useAtomValue(currentMoveAtom);
const isWhiteToPlay = board.turn() === "w";
useEffect(() => {
const bestLine = currentMove?.eval?.lines[0];
if (!bestLine) return;
const evalBar = getEvaluationBarValue(bestLine, board.turn() === "w");
const evalBar = getEvaluationBarValue(bestLine, isWhiteToPlay);
setEvalBar(evalBar);
}, [currentMove, board.turn()]);
}, [currentMove, isWhiteToPlay]);
return (
<Grid