+ setupPieces() {
+ // TODO: just scan board and get IDs, and addClass "bg-white" or "bg-black"
+ }
+
+ // TODO (NOTE: no flip here, always same view)
+ getPixelPosition(i, j, r) {
+ if (i < 0 || j < 0)
+ return [0, 0]; //piece vanishes
+ let x, y;
+ const sqSize = r.width / this.size.y;
+ const flipped = (this.playerColor == 'b');
+ const x = (flipped ? this.size.y - 1 - j : j) * sqSize,
+ y = (flipped ? this.size.x - 1 - i : i) * sqSize;
+ return [r.x + x, r.y + y];
+ }
+
+ initMouseEvents() {
+ const mousedown = (e) => {
+ if (e.touches && e.touches.length > 1)
+ e.preventDefault();
+ const cd = this.idToCoords(e.target.id);
+ if (cd) {
+ const move = this.doClick(cd);
+ if (move)
+ this.playPlusVisual(move);
+ }
+ };
+
+ if ('onmousedown' in window)
+ document.addEventListener("mousedown", mousedown);
+ if ('ontouchstart' in window)
+ document.addEventListener("touchstart", mousedown, {passive: false});
+ }
+
+ get size() {
+ return {
+ x: this.bsize,
+ y: this.bsize,
+ ratio: 1.630118
+ };
+ }
+
+ pieces() {
+ return {
+ 'p': {
+ "class": "pawn",
+ }
+ };
+ }
+
+ play(move) {
+ super.playOnBoard(move);
+ }
+
+ // TODO:
+ getCurrentScore(move) {
+ const oppCol = C.GetOppCol(this.turn);
+ // Search for connecting path of opp color: TODO
+ // ...
+ if (path found)
+ return (oppCol == "w" ? "1-0" : "0-1");
+ return "*";
+ }
+
+ playVisual(move) {
+ move.vanish.forEach(v => {
+// TODO: just get ID, and remClass "bg-white" or "bg-black" (in CSS: TODO)
+ });
+ move.appear.forEach(a => {
+// TODO: just get ID, and addClass "bg-white" or "bg-black" (in CSS: TODO)
+// this.g_pieces[a.x][a.y] = document.createElement("piece");
+// this.g_pieces[a.x][a.y].classList.add(this.pieces()[a.p]["class"]);
+// this.g_pieces[a.x][a.y].classList.add(a.c == "w" ? "white" : "black");
+// this.g_pieces[a.x][a.y].style.width = pieceWidth + "px";
+// this.g_pieces[a.x][a.y].style.height = pieceWidth + "px";
+ });