From: Benjamin Auder Date: Tue, 27 Nov 2018 13:05:47 +0000 (+0100) Subject: A few fixes, and write rules for Grand + Wildebeest X-Git-Url: https://git.auder.net/game/doc/html/current/mini-custom.min.css?a=commitdiff_plain;h=cf1303697774a12ef9bb154014a38797716944cf;p=vchess.git A few fixes, and write rules for Grand + Wildebeest --- diff --git a/public/images/pieces/Wildebeest/bc.svg b/public/images/pieces/Wildebeest/bc.svg index a67f271b..029ac314 100644 --- a/public/images/pieces/Wildebeest/bc.svg +++ b/public/images/pieces/Wildebeest/bc.svg @@ -1,27 +1,94 @@ - - - - 20 -Camel- (Solid) - Created with Sketch. - - - - - - - - - + + + + 20 -Camel- (Solid) + Created with Sketch. + + + + + + + + - - - - - - - Smashicons . - - - - - + + + + + + + Smashicons . + + + + + image/svg+xml + + + + + diff --git a/public/images/pieces/Wildebeest/bw.svg b/public/images/pieces/Wildebeest/bw.svg index 21a3c9a2..16e1c36d 100644 --- a/public/images/pieces/Wildebeest/bw.svg +++ b/public/images/pieces/Wildebeest/bw.svg @@ -1 +1,79 @@ -Madeby Grids \ No newline at end of file + +Madeby Gridsimage/svg+xml \ No newline at end of file diff --git a/public/images/pieces/Wildebeest/wc.svg b/public/images/pieces/Wildebeest/wc.svg index bc2b0301..3f1622f9 100644 --- a/public/images/pieces/Wildebeest/wc.svg +++ b/public/images/pieces/Wildebeest/wc.svg @@ -1,37 +1,164 @@ - - - - 20 -Camel- (Outline) - Created with Sketch. - - - - - - - - - - - - - - - - - - - + + + + 20 -Camel- (Outline) + Created with Sketch. + + + + + + + + + + + + + + + + + + - - - - - - - Smashicons . - - - - - + + + + + + + Smashicons . + + + + + image/svg+xml + + + + + + + + + + + diff --git a/public/images/pieces/Wildebeest/ww.svg b/public/images/pieces/Wildebeest/ww.svg index 54020bfa..561449c4 100644 --- a/public/images/pieces/Wildebeest/ww.svg +++ b/public/images/pieces/Wildebeest/ww.svg @@ -1 +1,114 @@ -Madeby Grids \ No newline at end of file + +Madeby Gridsimage/svg+xml \ No newline at end of file diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 42775dab..6cab3496 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -298,9 +298,9 @@ class ChessRules const V = VariantRules; const [sizeX,sizeY] = VariantRules.size; const shift = (color == "w" ? -1 : 1); - const firstRank = (color == 'w' ? sizeY-1 : 0); - const startRank = (color == "w" ? sizeY-2 : 1); - const lastRank = (color == "w" ? 0 : sizeY-1); + const firstRank = (color == 'w' ? sizeX-1 : 0); + const startRank = (color == "w" ? sizeX-2 : 1); + const lastRank = (color == "w" ? 0 : sizeX-1); if (x+shift >= 0 && x+shift < sizeX && x+shift != lastRank) { @@ -417,7 +417,7 @@ class ChessRules let step = finalSquares[castleSide][0] < y ? -1 : 1; for (i=y; i!=finalSquares[castleSide][0]; i+=step) { - if (this.isAttacked([x,i], oppCol) || (this.board[x][i] != V.EMPTY && + if (this.isAttacked([x,i], [oppCol]) || (this.board[x][i] != V.EMPTY && // NOTE: next check is enough, because of chessboard constraints (this.getColor(x,i) != c || ![V.KING,V.ROOK].includes(this.getPiece(x,i))))) { @@ -631,7 +631,7 @@ class ChessRules { const color = this.turn; this.play(move); - let res = this.isAttacked(this.kingPos[color], this.getOppCol(color)); + let res = this.isAttacked(this.kingPos[color], [this.getOppCol(color)]); this.undo(move); return res; } @@ -641,7 +641,7 @@ class ChessRules { this.play(move); const color = this.turn; //opponent - let res = this.isAttacked(this.kingPos[color], this.getOppCol(color)) + let res = this.isAttacked(this.kingPos[color], [this.getOppCol(color)]) ? [ JSON.parse(JSON.stringify(this.kingPos[color])) ] //need to duplicate! : [ ]; this.undo(move); @@ -773,7 +773,7 @@ class ChessRules { const color = this.turn; // No valid move: stalemate or checkmate? - if (!this.isAttacked(this.kingPos[color], this.getOppCol(color))) + if (!this.isAttacked(this.kingPos[color], [this.getOppCol(color)])) return "1/2"; // OK, checkmate return color == "w" ? "0-1" : "1-0"; diff --git a/public/javascripts/components/rules.js b/public/javascripts/components/rules.js index e7af056a..718021d0 100644 --- a/public/javascripts/components/rules.js +++ b/public/javascripts/components/rules.js @@ -52,7 +52,7 @@ Vue.component('my-rules', { for (let j=startY; j>=0 && j"; if (markArray.length>0 && markArray[i][j]) boardDiv += ""; diff --git a/public/javascripts/variants/Alice.js b/public/javascripts/variants/Alice.js index b7f5a3e1..5aa9ee81 100644 --- a/public/javascripts/variants/Alice.js +++ b/public/javascripts/variants/Alice.js @@ -223,7 +223,7 @@ class AliceRules extends ChessRules const mirrorSide = sideBoard[0][kp[0]][kp[1]] != VariantRules.EMPTY ? 1 : 2; let saveBoard = this.board; this.board = sideBoard[mirrorSide-1]; - let res = this.isAttacked(kp, this.getOppCol(color)); + let res = this.isAttacked(kp, [this.getOppCol(color)]); this.board = saveBoard; this.undoSide(move, sideBoard); return res; @@ -239,7 +239,7 @@ class AliceRules extends ChessRules let sideBoard = this.getSideBoard(mirrorSide); let saveBoard = this.board; this.board = sideBoard; - let res = this.isAttacked(this.kingPos[color], this.getOppCol(color)) + let res = this.isAttacked(this.kingPos[color], [this.getOppCol(color)]) ? [ JSON.parse(JSON.stringify(this.kingPos[color])) ] : [ ]; this.board = saveBoard; @@ -279,7 +279,7 @@ class AliceRules extends ChessRules let saveBoard = this.board; this.board = sideBoard; let res = "*"; - if (!this.isAttacked(this.kingPos[color], this.getOppCol(color))) + if (!this.isAttacked(this.kingPos[color], [this.getOppCol(color)])) res = "1/2"; else res = (color == "w" ? "0-1" : "1-0"); diff --git a/public/javascripts/variants/Antiking.js b/public/javascripts/variants/Antiking.js index f8c7465a..84f774a5 100644 --- a/public/javascripts/variants/Antiking.js +++ b/public/javascripts/variants/Antiking.js @@ -92,8 +92,8 @@ class AntikingRules extends ChessRules const c = this.turn; const oppCol = this.getOppCol(c); this.play(move) - let res = this.isAttacked(this.kingPos[c], oppCol) - || !this.isAttacked(this.antikingPos[c], oppCol); + let res = this.isAttacked(this.kingPos[c], [oppCol]) + || !this.isAttacked(this.antikingPos[c], [oppCol]); this.undo(move); return res; } @@ -103,7 +103,7 @@ class AntikingRules extends ChessRules let res = super.getCheckSquares(move); this.play(move); const c = this.turn; - if (!this.isAttacked(this.antikingPos[c], this.getOppCol(c))) + if (!this.isAttacked(this.antikingPos[c], [this.getOppCol(c)])) res.push(JSON.parse(JSON.stringify(this.antikingPos[c]))); this.undo(move); return res; @@ -134,8 +134,8 @@ class AntikingRules extends ChessRules { const color = this.turn; const oppCol = this.getOppCol(color); - if (!this.isAttacked(this.kingPos[color], oppCol) - && this.isAttacked(this.antikingPos[color], oppCol)) + if (!this.isAttacked(this.kingPos[color], [oppCol]) + && this.isAttacked(this.antikingPos[color], [oppCol])) { return "1/2"; } diff --git a/public/javascripts/variants/Atomic.js b/public/javascripts/variants/Atomic.js index b86e7822..a6934e73 100644 --- a/public/javascripts/variants/Atomic.js +++ b/public/javascripts/variants/Atomic.js @@ -127,7 +127,7 @@ class AtomicRules extends ChessRules res = false; // Otherwise, if we remain under check, move is not valid else - res = this.isAttacked(this.kingPos[c], oppCol); + res = this.isAttacked(this.kingPos[c], [oppCol]); this.undo(move); return res; } @@ -141,7 +141,7 @@ class AtomicRules extends ChessRules let res = [ ]; if (this.kingPos[c][0] < 0) res = [saveKingPos]; - else if (this.isAttacked(this.kingPos[c], this.getOppCol(c))) + else if (this.isAttacked(this.kingPos[c], [this.getOppCol(c)])) res = [ JSON.parse(JSON.stringify(this.kingPos[c])) ] this.undo(move); return res; @@ -153,7 +153,7 @@ class AtomicRules extends ChessRules const kp = this.kingPos[color]; if (kp[0] < 0) //king disappeared return color == "w" ? "0-1" : "1-0"; - if (!this.isAttacked(kp, this.getOppCol(color))) + if (!this.isAttacked(kp, [this.getOppCol(color)])) return "1/2"; // Checkmate return color == "w" ? "0-1" : "1-0"; diff --git a/public/javascripts/variants/Grand.js b/public/javascripts/variants/Grand.js index 8cdf6d7d..1409bcc5 100644 --- a/public/javascripts/variants/Grand.js +++ b/public/javascripts/variants/Grand.js @@ -63,8 +63,8 @@ class GrandRules extends ChessRules const V = VariantRules; const [sizeX,sizeY] = VariantRules.size; const shift = (color == "w" ? -1 : 1); - const startRanks = (color == "w" ? [sizeY-2,sizeY-3] : [1,2]); - const lastRanks = (color == "w" ? [0,1,2] : [sizeY-1,sizeY-2,sizeY-3]); + const startRanks = (color == "w" ? [sizeX-2,sizeX-3] : [1,2]); + const lastRanks = (color == "w" ? [0,1,2] : [sizeX-1,sizeX-2,sizeX-3]); if (x+shift >= 0 && x+shift < sizeX && x+shift != lastRanks[0]) { diff --git a/public/javascripts/variants/Wildebeest.js b/public/javascripts/variants/Wildebeest.js index f198eeb0..28f74d94 100644 --- a/public/javascripts/variants/Wildebeest.js +++ b/public/javascripts/variants/Wildebeest.js @@ -63,8 +63,8 @@ class WildebeestRules extends ChessRules const V = VariantRules; const [sizeX,sizeY] = VariantRules.size; const shift = (color == "w" ? -1 : 1); - const startRanks = (color == "w" ? [sizeY-2,sizeY-3] : [1,2]); - const lastRank = (color == "w" ? 0 : sizeY-1); + const startRanks = (color == "w" ? [sizeX-2,sizeX-3] : [1,2]); + const lastRank = (color == "w" ? 0 : sizeX-1); if (x+shift >= 0 && x+shift < sizeX && x+shift != lastRank) { @@ -155,17 +155,21 @@ class WildebeestRules extends ChessRules isAttackedByCamel(sq, colors) { return this.isAttackedBySlideNJump(sq, colors, - VariantRules.CAMEL, VariantRules.steps[VariantRules.CAMEL]); + VariantRules.CAMEL, VariantRules.steps[VariantRules.CAMEL], "oneStep"); } isAttackedByWildebeest(sq, colors) { const V = VariantRules; return this.isAttackedBySlideNJump(sq, colors, V.WILDEBEEST, - V.steps[V.KNIGHT].concat(V.steps[V.CAMEL])); + V.steps[V.KNIGHT].concat(V.steps[V.CAMEL]), "oneStep"); } - // TODO: stalemate is a win (?!) + checkGameEnd() + { + // No valid move: game is lost (stalemate is a win) + return this.turn == "w" ? "0-1" : "1-0"; + } static get VALUES() { return Object.assign( diff --git a/views/rules/Grand.pug b/views/rules/Grand.pug new file mode 100644 index 00000000..d5ca2016 --- /dev/null +++ b/views/rules/Grand.pug @@ -0,0 +1,52 @@ +p.boxed + | Two new pieces: marshall and cardinal. Bigger board. Orthodox rules with a few adaptations. + +h3 Specifications + +ul + li Chessboard: 10x10. + li Material: standard + marshall + cardinal. + li Non-capturing moves: standard (+ new pieces). + li Special moves: standard (see below). + li Captures: standard. + li End of game: standard. + +h3 Basics + +p. + Notation for marshall is M and cardinal is C. A marshall has the moving abilities of + a knight + a rook, while the cardinal equals a knight + a bishop. + +figure.diagram-container + .diagram + | fen:10/10/10/10/10/2R2Q4/10/4c5/10/10: + figcaption The black cardinal can take on c5 and f5. + +h3 Special moves + +p. + Castling is possible as in orthodox 8x8 game. The white king move to c1 or i1 + (one square to the left of bottom-right corner) for large (resp. small) castle. + Same for black on the other side. + +p. + Promotion is mandatory for a pawn reaching the last rank. However, they can only + promote into a friendly piece captured (which is back on the board). If none is + available, the promotion on last rank is impossible and the pawn cannot move. + +p Pawn promotion is possible (but not forced) on the two ranks before last. + +h3 End of the game + +p As in the orthodox game, win by checkmating the king. + +p. + Note: I changed the author's starting position, to facilitate random start. + Thus the castling rule was introduced compared to the rules described on chessvariants.com. + +h3 Credits + +p + | Grand chess page on + a(href="https://www.chessvariants.com/large.dir/freeling.html") chessvariants.com + | . diff --git a/views/rules/Wildebeest.pug b/views/rules/Wildebeest.pug new file mode 100644 index 00000000..cb883f9d --- /dev/null +++ b/views/rules/Wildebeest.pug @@ -0,0 +1,50 @@ +p.boxed + | Two new pieces: camel and wildebeest. Bigger board. Orthodox rules with a few adaptations. + +h3 Specifications + +ul + li Chessboard: 11x10. + li Material: standard + camel + wildebeest. + li Non-capturing moves: standard (+ new pieces). + li Special moves: standard (see below). + li Captures: standard. + li End of game: checkmate or stalemate win. + +h3 Basics + +p. + Notation for camel is C and wildebeest is W. A camel moves as a knight but with a + longer jump: 3 squares in one direction, and 1 left or right after that. + The wildebeest combines the moving abilities of a camel and a knight. + +figure.diagram-container + .diagram + | fen:11/11/11/11/11/4C6/11/11/11/11 w f2,h4,h6,f8,d8,b6,b4,d2: + figcaption Squares reachable by the white camel on e5. + +h3 Special moves + +p. + Castling is possible as in orthodox 8x8 game. The white king move to c1 or i1 + (one square to the left of bottom-right corner) for large (resp. small) castle. + Same for black on the other side. + +p. + Promotion occurs when pawns reach last rank. + They can only transform into a queen or a wildebeest. + +h3 End of the game + +p You can win by checkmating or stalemating the enemy king. + +p. + Note: the castling rule is more restrictive than described in the original rules. + I have a feeling that the game is OK like that, but I may change this soon. + +h3 Credits + +p + | Wildebeest page on + a(href="https://www.chessvariants.com/large.dir/wildebeest.html") chessvariants.com + | .