X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=4805f174b55773fc5e5a3e79dc9792d8a8b6dfaf;hb=0c44c6768654f7127e36aa75beee58d61df4fc64;hp=9eb18fcfc66663d74a71086bc84f3da3a43661de;hpb=99ea245370e6de1e3122f61fc18c2a557b8ae711;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 9eb18fc..4805f17 100644 --- a/base_rules.js +++ b/base_rules.js @@ -118,13 +118,13 @@ export default class ChessRules { //////////////////// // COORDINATES UTILS - // a3 --> {x:10, y:3} + // 3a --> {x:3, y:10} static SquareToCoords(sq) { return ArrayFun.toObject(["x", "y"], [0, 1].map(i => parseInt(sq[i], 36))); } - // {x:1, y:12} --> 1c + // {x:11, y:12} --> bc static CoordsToSquare(cd) { return Object.values(cd).map(c => c.toString(36)).join(""); } @@ -162,12 +162,12 @@ export default class ChessRules { // Turn "wb" into "B" (for FEN) board2fen(b) { - return b[0] == "w" ? b[1].toUpperCase() : b[1]; + return (b[0] == "w" ? b[1].toUpperCase() : b[1]); } // Turn "p" into "bp" (for board) fen2board(f) { - return f.charCodeAt(0) <= 90 ? "w" + f.toLowerCase() : "b" + f; + return (f.charCodeAt(0) <= 90 ? "w" + f.toLowerCase() : "b" + f); } // Setup the initial random-or-not (asymmetric-or-not) position @@ -672,7 +672,7 @@ export default class ChessRules { } else this.r_pieces = { 'w': {}, 'b': {} }; - let chessboard = + let chessboard = document.getElementById(this.containerId).querySelector(".chessboard"); if (!r) r = chessboard.getBoundingClientRect(); @@ -1065,13 +1065,7 @@ export default class ChessRules { // Am I allowed to move thing at square x,y ? canIplay(x, y) { - return ( - this.playerColor == this.turn && - ( - (typeof x == "number" && this.getColor(x, y) == this.turn) || - (typeof x == "string" && x == this.turn) //reserve - ) - ); + return (this.playerColor == this.turn && this.getColor(x, y) == this.turn); } //////////////////////// @@ -1342,13 +1336,11 @@ export default class ChessRules { } } if (!this.options["rifle"]) - m.appear.pop(); //nothin appears + m.appear.pop(); //nothing appears } }); } -// TODO: pawnfall + Cannibal issues - pawnPostProcess(moves, color, oppCol) { let moreMoves = []; const lastRank = (color == "w" ? 0 : this.size.x - 1); @@ -1403,7 +1395,6 @@ export default class ChessRules { m.appear[0].x == m.start.x && m.appear[0].y == m.start.y ) { - const promotionPiece0 = this.pawnSpecs.promotions[0]; m.appear[0].p = this.pawnPromotions[0]; for (let i=1; i store only indices in appear/vanish ? const minSize = Math.min(move.appear.length, move.vanish.length); - if (this.hasReserve && !move.pawnfall) { + if ( + this.hasReserve && + // Warning; atomic pawn removal isn't a capture + (!this.options["atomic"] || !this.rempawn || this.movesCount >= 1) + ) { const color = this.turn; for (let i=minSize; i { - // TODO - }); - move.births.forEach(bth => { - // TODO - }); } play(move) {