From: Benjamin Auder Date: Fri, 27 Mar 2020 23:02:03 +0000 (+0100) Subject: Fix Apocalypse (again...), moveslist highlighting and get a first working draft of... X-Git-Url: https://git.auder.net/js/DESCRIPTION?a=commitdiff_plain;h=b866a62ab3d1d427688954383ed7035111b0e132;p=vchess.git Fix Apocalypse (again...), moveslist highlighting and get a first working draft of a tiny subset of Dynamo (knights push/pull + 'dynamate') --- diff --git a/client/public/images/pieces/Dynamo/pstep.svg b/client/public/images/pieces/Dynamo/pstep.svg new file mode 100644 index 00000000..17b0440a --- /dev/null +++ b/client/public/images/pieces/Dynamo/pstep.svg @@ -0,0 +1,84 @@ + + + + + + + + + + image/svg+xml + + + + + + +   + P + + diff --git a/client/public/images/pieces/Dynamo/raus.svg b/client/public/images/pieces/Dynamo/raus.svg new file mode 100644 index 00000000..1d831147 --- /dev/null +++ b/client/public/images/pieces/Dynamo/raus.svg @@ -0,0 +1,84 @@ + + + + + + + + + + image/svg+xml + + + + + + +   + R + + diff --git a/client/public/images/pieces/Dynamo/shift_1.svg b/client/public/images/pieces/Dynamo/shift_1.svg new file mode 100644 index 00000000..3bcd08bd --- /dev/null +++ b/client/public/images/pieces/Dynamo/shift_1.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/client/public/images/pieces/Dynamo/shift_2.svg b/client/public/images/pieces/Dynamo/shift_2.svg new file mode 100644 index 00000000..4f7eeb51 --- /dev/null +++ b/client/public/images/pieces/Dynamo/shift_2.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/client/public/images/pieces/Dynamo/shift_3.svg b/client/public/images/pieces/Dynamo/shift_3.svg new file mode 100644 index 00000000..50b2d025 --- /dev/null +++ b/client/public/images/pieces/Dynamo/shift_3.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/client/public/images/pieces/Dynamo/shift_4.svg b/client/public/images/pieces/Dynamo/shift_4.svg new file mode 100644 index 00000000..96557131 --- /dev/null +++ b/client/public/images/pieces/Dynamo/shift_4.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/client/public/images/pieces/Dynamo/shift_5.svg b/client/public/images/pieces/Dynamo/shift_5.svg new file mode 100644 index 00000000..b2237d73 --- /dev/null +++ b/client/public/images/pieces/Dynamo/shift_5.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/client/public/images/pieces/Dynamo/shift_6.svg b/client/public/images/pieces/Dynamo/shift_6.svg new file mode 100644 index 00000000..4897edc3 --- /dev/null +++ b/client/public/images/pieces/Dynamo/shift_6.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/client/public/images/pieces/Dynamo/shift_7.svg b/client/public/images/pieces/Dynamo/shift_7.svg new file mode 100644 index 00000000..59970898 --- /dev/null +++ b/client/public/images/pieces/Dynamo/shift_7.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/client/public/images/pieces/SOURCE b/client/public/images/pieces/SOURCE index 9cb132af..ada138cd 100644 --- a/client/public/images/pieces/SOURCE +++ b/client/public/images/pieces/SOURCE @@ -5,3 +5,7 @@ Some fairy pieces found on the web and icon scout: https://iconscout.com/ PNG images for Eightpieces from https://greenchess.net/index.php and Jeff Kubach design. Images of the Hawk and Elephant were designed by "Couch Tomato #2218" on Discord, for the pychess-variants website (http://pychess-variants.herokuapp.com/) +For Dynamo: +https://commons.wikimedia.org/wiki/File:Font_P.svg +https://commons.wikimedia.org/wiki/File:Font_R.svg +https://svgsilh.com/image/3203304.html diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index 91d138ef..6eaf43ce 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -53,7 +53,7 @@ div | {{ notation(moves[moveIdx]) }} .td( v-if="moveIdx < moves.length-1" - :class="{'highlight-lm': highlightBlackmove(moveIdx)}" + :class="{'highlight-lm': highlightBlackmove(moveIdx+1)}" @click="() => gotoMove(moveIdx+1)" ) | {{ notation(moves[moveIdx+1]) }} @@ -139,8 +139,8 @@ export default { }, highlightBlackmove: function(moveIdx) { return ( - this.cursor == moveIdx + 1 || - (this.show == "byrow" && this.cursor == moveIdx + 2) + this.cursor == moveIdx || + (this.show == "byrow" && this.cursor == moveIdx + 1) ); }, gotoMove: function(index) { diff --git a/client/src/variants/Apocalypse.js b/client/src/variants/Apocalypse.js index abcfd703..c136ff28 100644 --- a/client/src/variants/Apocalypse.js +++ b/client/src/variants/Apocalypse.js @@ -274,29 +274,44 @@ export class ApocalypseRules extends ChessRules { return ( ( m.vanish[0].p == V.KNIGHT && - (m.vanish.length == 1 || m.vanish[1].c != m.vanish[0].c) - ) - || - ( - // Promotion attempt - m.end.x == (m.vanish[0].c == "w" ? 0 : V.size.x - 1) && - other.vanish.length == 2 && - other.vanish[1].p == V.KNIGHT && - other.vanish[1].c == m.vanish[0].c - ) - || - ( - // Moving attempt - !movingLikeCapture(m) && - other.start.x == m.end.x && - other.start.y == m.end.y + ( + m.vanish.length == 1 || + m.vanish[1].c != m.vanish[0].c || + // Self-capture attempt + ( + !other.illegal && + other.end.x == m.end.x && + other.end.y == m.end.y + ) + ) ) || ( - // Capture attempt - movingLikeCapture(m) && - other.end.x == m.end.x && - other.end.y == m.end.y + m.vanish[0].p == V.PAWN && + !other.illegal && + ( + ( + // Promotion attempt + m.end.x == (m.vanish[0].c == "w" ? 0 : V.size.x - 1) && + other.vanish.length == 2 && + other.vanish[1].p == V.KNIGHT && + other.vanish[1].c == m.vanish[0].c + ) + || + ( + // Moving attempt + !movingLikeCapture(m) && + other.start.x == m.end.x && + other.start.y == m.end.y + ) + || + ( + // Capture attempt + movingLikeCapture(m) && + other.end.x == m.end.x && + other.end.y == m.end.y + ) + ) ) ); }; diff --git a/client/src/variants/Dynamo.js b/client/src/variants/Dynamo.js index 4d443eb5..7a794ea2 100644 --- a/client/src/variants/Dynamo.js +++ b/client/src/variants/Dynamo.js @@ -1,4 +1,10 @@ -import { ChessRules } from "@/base_rules"; +import { ChessRules, Move, PiPo } from "@/base_rules"; + +// TODO: need FEN lastmove pour interdire défaire dernière poussée +// --> check appear et vanish totally reversed. + +// TODO: pawn promotions by push (en + des promotions standard) +// --> similar to Zen promotions. export class DynamoRules extends ChessRules { canIplay(side, [x, y]) { @@ -6,29 +12,6 @@ export class DynamoRules extends ChessRules { return true; } - // NOTE: to push a piece out of the board, make it slide until our piece - // (doing the action, moving or not) - getPotentialMovesFrom([x, y]) { - const color = this.turn; - let moves = []; - if (this.getColor(x, y) != color) { - // Push or pull something: freely only if subTurn == 1 - if (this.subTurn == 2) { - // I know that someone is pushing/pulling: find out who, - // and deduce my possible squares (or exit). - // TODO - } else { - // Look in every direction for a friendly pusher/puller. - // This means that the action is done without moving. - // TODO - } - } else { - // My piece: fill first with normal moves (if any), - // and add pushes/pulls (if any). - // TODO - } - } - getPPpath(m) { let imgName = ""; if (m.vanish.length == 1) imgName = "empty"; @@ -40,8 +23,8 @@ export class DynamoRules extends ChessRules { else { const deltaX = Math.abs(m.appear[1].x - m.vanish[1].x); const deltaY = Math.abs(m.appear[1].y - m.vanish[1].y); - if (deltaX == 0) imgName = "shift" + deltaY; - else if (deltaY == 0) imgName = "shift" + deltaX; + if (deltaX == 0) imgName = "shift_" + deltaY; + else if (deltaY == 0) imgName = "shift_" + deltaX; else // Special knight push/pull: just print "P" imgName = "pstep"; @@ -50,6 +33,86 @@ export class DynamoRules extends ChessRules { return "Dynamo/" + imgName; } + getPactions(sq, by, color) { + const [x, y] = sq; + let moves = []; + let squares = {}; +// const lineAdd = (allowedPieces) = { +// // attacking piece must be of the allowed types +// }; + if (!by) { + // Look in all directions for a "color" piece + for (let step of V.steps[V.KNIGHT]) { + const xx = x + step[0], + yy = y + step[1]; + if ( + V.OnBoard(xx, yy) && + this.getPiece(xx, yy) == V.KNIGHT && + this.getColor(xx, yy) == color + ) { + const px = x - step[0], + py = y - step[1]; + if (V.OnBoard(px, py) && this.board[px][py] == V.EMPTY) { + const hash = "s" + px + py; + if (!squares[hash]) { + squares[hash] = true; + moves.push(this.getBasicMove([x, y], [px, py])); + } + } else { + const hash = "s" + xx + yy; + if (!squares[hash]) { + squares[hash] = true; + moves.push( + new Move({ + start: { x: x, y: y }, + end: { x: xx, y: yy }, + appear: [], + vanish: [ + new PiPo({ + x: x, + y: y, + p: this.getPiece(x, y), + c: oppCol + }) + ] + }) + ); + } + } + } + } + for (let step in V.steps[V.ROOK]) { + // color is enemy, so no pawn pushes: king, rook and queen + } + for (let step in V.steps[V.BISHOP]) { + // King, bishop, queen, and possibly pawns attacks + } + } +// else { +// // TODO: probably in a different function for now. +// } + return moves; + } + + // NOTE: to push a piece out of the board, make it slide until our piece + // (doing the action, moving or not) + getPotentialMovesFrom([x, y]) { + const color = this.turn; + const oppCol = V.GetOppCol(color); + if (this.getColor(x, y) != color) { + // Look in every direction for a friendly pusher/puller. + // This means that the action is done without moving. + return this.getPactions([x, y], null, color); + } else { + // Playing my pieces: do they attack an enemy? + // If yes ... TODO + //this.getPattacks(sq, [x, y]); + // Temporary: + return super.getPotentialMovesFrom([x, y]); + } + return []; //never reached + } + isAttackedBySlideNJump([x, y], color, piece, steps, oneStep) { for (let step of steps) { let rx = x + step[0],