X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=variants%2FHex%2Fclass.js;h=0797c91e42c0498699b8080f3d4bcddf50ba364a;hp=925507eb2d7074e7ba3388d51bc7eb4df8347b27;hb=f31de5e46015a93dca20765da61670035ce8f491;hpb=e7d409fc03a8cd8459a2b41f9fef51c0a3fb0d6d diff --git a/variants/Hex/class.js b/variants/Hex/class.js index 925507e..0797c91 100644 --- a/variants/Hex/class.js +++ b/variants/Hex/class.js @@ -32,10 +32,12 @@ export default class HexRules extends ChessRules { get hasReserve() { return false; } - get noAnimate() { return true; } + get clickOnly() { + return true; + } doClick(coords) { if ( @@ -72,10 +74,13 @@ export default class HexRules extends ChessRules { return res; } - genRandInitFen() { + genRandInitBaseFen() { // NOTE: size.x == size.y (square boards) const emptyCount = C.FenEmptySquares(this.size.x); - return (emptyCount + "/").repeat(this.size.x).slice(0, -1) + " w 0"; + return { + fen: (emptyCount + "/").repeat(this.size.x).slice(0, -1) + " w 0", + o: {} + }; } getSvgChessboard() { @@ -161,30 +166,11 @@ export default class HexRules extends ChessRules { } } - 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.buildMoveStack(move); - } - }; - - if ('onmousedown' in window) { - document.addEventListener("mousedown", mousedown); - document.addEventListener("wheel", - (e) => this.rescale(e.deltaY < 0 ? "up" : "down")); - } - if ('ontouchstart' in window) - document.addEventListener("touchstart", mousedown, {passive: false}); - } - get size() { const baseRatio = 1.6191907514450865; //2801.2 / 1730, "widescreen" - const rotate = window.innerWidth < window.innerHeight; //"vertical screen" + const rc = + document.getElementById(this.containerId).getBoundingClientRect(); + const rotate = rc.width < rc.height; //"vertical screen" return { x: this.options["bsize"], y: this.options["bsize"],