Skip to content

Commit

Permalink
fix js errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Disservin committed Apr 10, 2023
1 parent f8eebf2 commit 4c85131
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/ts/UciFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function filterUCIInfo(str: string): EngineInfo {
engineInfo.depth = tokens[i + 1];
} else if (token === "seldepth") engineInfo.seldepth = tokens[i + 1];
else if (token === "score") {
engineInfo.score = tokens[i + 1] + tokens[i + 2];
engineInfo.score = tokens[i + 1] + " " + tokens[i + 2];
} else if (token === "time") {
engineInfo.time = tokens[i + 1];
} else if (token === "nodes") {
Expand Down
24 changes: 16 additions & 8 deletions src/views/Analysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,24 @@ export default defineComponent({
getPlayedMoves() {
return this.moveHistory.trim();
},
playMoves(moves: string) {
const movesArray = moves.split(" ");
console.log(moves, movesArray);
async playMoves(moves: string) {
const movesArray = moves.trim().split(" ");
for (let i = 0; i < movesArray.length; i++) {
const move = movesArray[i];
if (move !== "" && this.game.move(move)) {
this.moveHistory += move + " ";
if (this.game.move(move) === null) {
return;
}
this.moveHistory += move + " ";
}
await this.sendEngineCommand("stop");
await this.sendEngineCommand("go");
this.engineLines.clear();
this.cg?.set({
fen: this.game.fen(),
turnColor: this.toColor(),
Expand All @@ -183,9 +189,6 @@ export default defineComponent({
});
this.currentFen = this.game.fen();
this.sendEngineCommand("stop");
this.sendEngineCommand("go");
},
handleKeydown(event: KeyboardEvent) {
event.preventDefault();
Expand Down Expand Up @@ -308,6 +311,11 @@ export default defineComponent({
if (line != "" && line.startsWith("info")) {
const filtered = filterUCIInfo(line);
if (Object.keys(filtered).length === 0) {
return;
}
// only update changed values
this.engine_info = { ...this.engine_info, ...filtered };
Expand Down

0 comments on commit 4c85131

Please sign in to comment.