Render the Go board and connect it to the core #42

Merged
savanni merged 5 commits from kifu/render-goban into main 2023-05-16 14:22:20 +00:00
2 changed files with 1 additions and 49 deletions
Showing only changes of commit a779220173 - Show all commits

View File

@ -52,7 +52,6 @@ export class GoBoard {
};
this.canvas.onclick = (_) => {
console.log("clicked on ", this.cursorLocation);
if (this.cursorLocation) {
const intersection =
this.board.spaces[boardAddress(this.board.size, this.cursorLocation)];
@ -60,7 +59,6 @@ export class GoBoard {
case "Unplayable":
break;
case "Empty":
console.log("need to run action: ", intersection.content);
onClick(intersection.content);
break;
case "Filled":
@ -73,7 +71,6 @@ export class GoBoard {
}
setBoard(board: BoardElement) {
console.log("setting an updated board: ", board);
this.board = board;
this.pen = new Pen(
@ -93,22 +90,6 @@ export class GoBoard {
return null;
}
/*
ctx.fillStyle = "rgb(100, 0, 0)";
ctx.beginPath();
ctx.moveTo(100, 100);
ctx.arc(100, 100, 25, 0, 2.0 * Math.PI);
ctx.closePath();
ctx.fill();
ctx.fillStyle = "rgb(0, 0, 100)";
ctx.beginPath();
ctx.moveTo(200, 100);
ctx.arc(200, 100, 25, 0, 2.0 * Math.PI);
ctx.closePath();
ctx.fill();
*/
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
ctx.lineWidth = 2;

View File

@ -1,17 +1,7 @@
import { GoBoard } from "./components/Board";
import { CoreRequest, CoreResponse } from "core-types";
import { CoreApi, initCore } from "./coreApi";
import { assertNever } from "./assertNever";
/*
const processResponse = (response: CoreResponse) => {
const root = document.getElementById("root");
if (!root) {
return;
}
};
*/
// import { assertNever } from "./assertNever";
class UIState {
private currentView: GoBoard | null;
@ -67,25 +57,6 @@ const main = async () => {
const uiState = new UIState(coreApi, root);
uiState.processResponse(response);
/*
console.log("playing field response: ", response);
if (!root) {
alert("could not retrieve the app root container");
return;
}
const board = new GoBoard({
board: response.content.board,
onClick: async (request: CoreRequest) => {
const response = await coreApi.dispatch(request);
},
});
root.appendChild(board.canvas);
console.log("constructed board: ", board);
board.renderBoard();
*/
};
main();