From: Benjamin Auder Date: Tue, 19 Dec 2023 19:06:19 +0000 (+0100) Subject: Fix Coregal X-Git-Url: https://git.auder.net/assets/js/%7B%7B%20path%28%27fos_user_profile_edit%27%29%20%7D%7D?a=commitdiff_plain;h=8f87962339f2bcaeb4c2716d0588a63449a68bde;p=xogo.git Fix Coregal --- diff --git a/base_rules.js b/base_rules.js index 0f950a2..699b1d8 100644 --- a/base_rules.js +++ b/base_rules.js @@ -1686,10 +1686,6 @@ export default class ChessRules { getPotentialMovesOf(piece, [x, y]) { const color = this.getColor(x, y); const stepSpec = this.getStepSpec(color, x, y, piece); - - // TODO: pawns, coregal -console.log(stepSpec); - let squares = []; if (stepSpec.attack) { squares = this.findDestSquares( @@ -2254,7 +2250,7 @@ console.log(stepSpec); } // Update castling flags if start or arrive from/at rook/king locations move.appear.concat(move.vanish).forEach(psq => { - if ((!!king && psq.p == king) || this.isKing(0, 0, psq.p)) + if ((king && psq.p == king) || (!king && this.isKing(0, 0, psq.p))) castleFlags[psq.c] = [this.size.y, this.size.y]; // NOTE: not "else if" because king can capture enemy rook... let c = ""; diff --git a/pieces/CREDITS b/pieces/CREDITS new file mode 100644 index 0000000..6950ef0 --- /dev/null +++ b/pieces/CREDITS @@ -0,0 +1,3 @@ +white_castle, black_castle : +https://www.iconpacks.net/free-icon/castle-1802.html +https://uxwing.com/castle-icon/ diff --git a/pieces/black_castle.svg b/pieces/black_castle.svg new file mode 100644 index 0000000..ced0f90 --- /dev/null +++ b/pieces/black_castle.svg @@ -0,0 +1,40 @@ + + diff --git a/pieces/white_castle.svg b/pieces/white_castle.svg new file mode 100644 index 0000000..78e0814 --- /dev/null +++ b/pieces/white_castle.svg @@ -0,0 +1,46 @@ + + + + + + + + + diff --git a/variants/Coregal/class.js b/variants/Coregal/class.js index 1d746d6..23f67c7 100644 --- a/variants/Coregal/class.js +++ b/variants/Coregal/class.js @@ -75,11 +75,12 @@ export default class CoregalRules extends ChessRules { }; } - pieces() { - let res = super.pieces(); + pieces(color, x, y) { + let res = super.pieces(color, x, y); res['l'] = JSON.parse(JSON.stringify(res['q'])); // TODO: CSS royal queen symbol (with cross?) res['l']["class"] = "royal_queen"; + res['='] = {"class": "castle"}; //for castle display return res; } @@ -120,8 +121,10 @@ export default class CoregalRules extends ChessRules { this.relPos[c][p] == '0' ? [1, 2] : [2, 3], //0 == left this.relPos[c][p] == '1' ? [6, 5] : [5, 4] //1 == right ]; - const moves = + let moves = super.getCastleMoves([x, y], finalSquares, null, this.castleFlags[p][c]); + if (p == 'l') + moves.forEach(m => m.choice = '='); //required (for display) return moves; } diff --git a/variants/Coregal/style.css b/variants/Coregal/style.css index b0046d0..668e543 100644 --- a/variants/Coregal/style.css +++ b/variants/Coregal/style.css @@ -6,3 +6,10 @@ piece.black.royal_queen { piece.white.royal_queen { background-image: url('/pieces/Coregal/white_royal_queen.svg'); } + +piece.black.castle { + background-image: url('/pieces/black_castle.svg'); +} +piece.white.castle { + background-image: url('/pieces/white_castle.svg'); +}