Skip to content

Commit

Permalink
fix: reformat gtp.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Terkwood committed May 13, 2021
1 parent 6ad63a7 commit 1942163
Showing 1 changed file with 25 additions and 31 deletions.
56 changes: 25 additions & 31 deletions browser/src/modules/shims/gtp.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,41 +215,35 @@ class WebSocketController extends EventEmitter {
this.resolveMakeMove = undefined;
}
});
sabaki.events.on(
"sync-server-ahead",
({ playerUp, moves }) => {
sabaki.generateMove();

let syncLastMove = moves[moves.length - 1];
let sabakiCoord = syncLastMove.coord
? this.board.vertex2coord([
syncLastMove.coord.x,
syncLastMove.coord.y,
])
: "pass";

if (this.resolveMoveMade) {
console.log("Resolving outstanding move...");
this.resolveMoveMade({
id: null,
content: sabakiCoord,
error: false,
});
}
sabaki.events.on("sync-server-ahead", ({ playerUp, moves }) => {
sabaki.generateMove();

let syncLastMove = moves[moves.length - 1];
let sabakiCoord = syncLastMove.coord
? this.board.vertex2coord([syncLastMove.coord.x, syncLastMove.coord.y])
: "pass";

if (this.resolveMoveMade) {
console.log("Resolving outstanding move...");
this.resolveMoveMade({
id: null,
content: sabakiCoord,
error: false,
});
}

let newPlayerUp = otherPlayer(playerUp);
let newPlayerUp = otherPlayer(playerUp);

// In case white needs to dismiss its initial screen
sabaki.events.emit("they-moved", { playerUp: newPlayerUp });
// In case white needs to dismiss its initial screen
sabaki.events.emit("they-moved", { playerUp: newPlayerUp });

// - In case we need to show that the opponent passed
// - Used by BugoutSync to delay sync requests after move
sabaki.events.emit("bugout-move-made", { coord: syncLastMove.coord });
// - In case we need to show that the opponent passed
// - Used by BugoutSync to delay sync requests after move
sabaki.events.emit("bugout-move-made", { coord: syncLastMove.coord });

this.genMoveInProgress = false;
sabaki.events.emit("gen-move-completed", { done: true });
}
);
this.genMoveInProgress = false;
sabaki.events.emit("gen-move-completed", { done: true });
});

sabaki.events.on("bugout-turn", ({ turn }) => (this.turn = turn));

Expand Down

0 comments on commit 1942163

Please sign in to comment.