Render the Go board and connect it to the core #42
|
@ -52,7 +52,6 @@ export class GoBoard {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.canvas.onclick = (_) => {
|
this.canvas.onclick = (_) => {
|
||||||
console.log("clicked on ", this.cursorLocation);
|
|
||||||
if (this.cursorLocation) {
|
if (this.cursorLocation) {
|
||||||
const intersection =
|
const intersection =
|
||||||
this.board.spaces[boardAddress(this.board.size, this.cursorLocation)];
|
this.board.spaces[boardAddress(this.board.size, this.cursorLocation)];
|
||||||
|
@ -60,7 +59,6 @@ export class GoBoard {
|
||||||
case "Unplayable":
|
case "Unplayable":
|
||||||
break;
|
break;
|
||||||
case "Empty":
|
case "Empty":
|
||||||
console.log("need to run action: ", intersection.content);
|
|
||||||
onClick(intersection.content);
|
onClick(intersection.content);
|
||||||
break;
|
break;
|
||||||
case "Filled":
|
case "Filled":
|
||||||
|
@ -73,7 +71,6 @@ export class GoBoard {
|
||||||
}
|
}
|
||||||
|
|
||||||
setBoard(board: BoardElement) {
|
setBoard(board: BoardElement) {
|
||||||
console.log("setting an updated board: ", board);
|
|
||||||
this.board = board;
|
this.board = board;
|
||||||
|
|
||||||
this.pen = new Pen(
|
this.pen = new Pen(
|
||||||
|
@ -93,22 +90,6 @@ export class GoBoard {
|
||||||
return null;
|
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.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||||
|
|
||||||
ctx.lineWidth = 2;
|
ctx.lineWidth = 2;
|
||||||
|
|
|
@ -1,17 +1,7 @@
|
||||||
import { GoBoard } from "./components/Board";
|
import { GoBoard } from "./components/Board";
|
||||||
import { CoreRequest, CoreResponse } from "core-types";
|
import { CoreRequest, CoreResponse } from "core-types";
|
||||||
import { CoreApi, initCore } from "./coreApi";
|
import { CoreApi, initCore } from "./coreApi";
|
||||||
import { assertNever } from "./assertNever";
|
// import { assertNever } from "./assertNever";
|
||||||
|
|
||||||
/*
|
|
||||||
const processResponse = (response: CoreResponse) => {
|
|
||||||
const root = document.getElementById("root");
|
|
||||||
if (!root) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
class UIState {
|
class UIState {
|
||||||
private currentView: GoBoard | null;
|
private currentView: GoBoard | null;
|
||||||
|
@ -67,25 +57,6 @@ const main = async () => {
|
||||||
|
|
||||||
const uiState = new UIState(coreApi, root);
|
const uiState = new UIState(coreApi, root);
|
||||||
uiState.processResponse(response);
|
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();
|
main();
|
||||||
|
|
Loading…
Reference in New Issue