From: Benjamin Auder <benjamin.auder@somewhere> Date: Mon, 20 Jun 2022 17:43:39 +0000 (+0200) Subject: Chakart ready for testing X-Git-Url: https://git.auder.net/variants/Chakart/pieces/img/doc/DESCRIPTION?a=commitdiff_plain;h=cc9fe4f154ec244cbec468d1a3b5845e56cb378d;p=xogo.git Chakart ready for testing --- diff --git a/TODO b/TODO index 2aeb9ae..a17d5c3 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,3 @@ -Chakart egg : afficher image du bonus sur la case d'arrivée, clignotante, pendant 1 seconde ? -Invisible queen : afficher "??" sur la case de départ jusqu'au coup adverse (qui l'efface du coup) ? - add variants : Dark Racing Kings ? Checkered-Teleport ? diff --git a/pieces/chakart_mystery_black.svg b/pieces/chakart_mystery_black.svg new file mode 100644 index 0000000..4950f93 --- /dev/null +++ b/pieces/chakart_mystery_black.svg @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + version="1.0" + width="900pt" + height="900pt" + viewBox="0 0 900 900" + preserveAspectRatio="xMidYMid" + id="svg10" + sodipodi:docname="chakart_mystery_black.svg" + inkscape:version="1.2 (dc2aedaf03, 2022-05-15)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <defs + id="defs14" /> + <sodipodi:namedview + id="namedview12" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + inkscape:document-units="pt" + showgrid="false" + inkscape:zoom="0.51035156" + inkscape:cx="574.11405" + inkscape:cy="698.53808" + inkscape:window-width="960" + inkscape:window-height="1060" + inkscape:window-x="0" + inkscape:window-y="20" + inkscape:window-maximized="1" + inkscape:current-layer="svg10" /> + <metadata + id="metadata2"> +Created by potrace 1.15, written by Peter Selinger 2001-2017 +</metadata> + <g + transform="matrix(0.08869513,0,0,-0.05979362,67.456324,833.00729)" + fill="#000000" + stroke="none" + id="g8"> + <path + d="M 4105,12794 C 3401,12755 2785,12602 2223,12326 1482,11962 882,11428 500,10794 171,10249 0,9694 0,9170 c 0,-341 144,-652 426,-920 272,-258 627,-380 1016,-349 307,25 548,135 758,348 175,177 285,372 405,721 160,461 311,777 505,1053 95,134 275,311 374,367 243,136 537,200 916,200 451,-1 781,-112 1064,-358 280,-244 426,-561 426,-927 0,-253 -53,-412 -223,-665 -144,-215 -268,-339 -927,-925 -557,-496 -915,-842 -1110,-1069 -349,-408 -608,-949 -695,-1450 -47,-276 -69,-695 -46,-891 40,-341 146,-579 345,-778 246,-246 587,-372 960,-354 483,23 828,244 1016,652 52,111 88,233 155,530 32,138 73,306 92,375 36,135 114,308 183,409 118,174 335,399 718,743 983,884 1336,1221 1526,1458 178,223 381,540 481,754 300,638 337,1470 99,2197 -161,495 -424,919 -809,1305 -667,670 -1581,1070 -2695,1179 -149,15 -706,27 -855,19 z" + id="path4" /> + <path + d="m 3980,2905 c -340,-52 -607,-191 -851,-442 -293,-302 -427,-693 -390,-1135 20,-238 60,-388 153,-570 131,-256 353,-465 642,-604 164,-78 282,-113 470,-139 305,-42 608,8 877,143 339,171 584,439 700,767 111,317 116,701 12,1020 -68,210 -196,409 -369,575 -226,217 -468,336 -789,386 -110,17 -340,16 -455,-1 z" + id="path6" /> + </g> +</svg> diff --git a/pieces/chakart_mystery_white.svg b/pieces/chakart_mystery_white.svg new file mode 100644 index 0000000..f2b7e06 --- /dev/null +++ b/pieces/chakart_mystery_white.svg @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + version="1.0" + width="900pt" + height="900pt" + viewBox="0 0 900 900" + preserveAspectRatio="xMidYMid" + id="svg10" + sodipodi:docname="chakart_mystery_white.svg" + inkscape:version="1.2 (dc2aedaf03, 2022-05-15)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <defs + id="defs14" /> + <sodipodi:namedview + id="namedview12" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + inkscape:document-units="pt" + showgrid="false" + inkscape:zoom="0.51035156" + inkscape:cx="574.11405" + inkscape:cy="700.49751" + inkscape:window-width="960" + inkscape:window-height="1060" + inkscape:window-x="0" + inkscape:window-y="20" + inkscape:window-maximized="1" + inkscape:current-layer="svg10" /> + <metadata + id="metadata2"> +Created by potrace 1.15, written by Peter Selinger 2001-2017 +</metadata> + <g + transform="matrix(0.08642939,0,0,-0.05855475,76.705611,825.79514)" + fill="#ffffff" + stroke="#000000" + stroke-width="200" + id="g8"> + <path + d="M 4105,12794 C 3401,12755 2785,12602 2223,12326 1482,11962 882,11428 500,10794 171,10249 0,9694 0,9170 c 0,-341 144,-652 426,-920 272,-258 627,-380 1016,-349 307,25 548,135 758,348 175,177 285,372 405,721 160,461 311,777 505,1053 95,134 275,311 374,367 243,136 537,200 916,200 451,-1 781,-112 1064,-358 280,-244 426,-561 426,-927 0,-253 -53,-412 -223,-665 -144,-215 -268,-339 -927,-925 -557,-496 -915,-842 -1110,-1069 -349,-408 -608,-949 -695,-1450 -47,-276 -69,-695 -46,-891 40,-341 146,-579 345,-778 246,-246 587,-372 960,-354 483,23 828,244 1016,652 52,111 88,233 155,530 32,138 73,306 92,375 36,135 114,308 183,409 118,174 335,399 718,743 983,884 1336,1221 1526,1458 178,223 381,540 481,754 300,638 337,1470 99,2197 -161,495 -424,919 -809,1305 -667,670 -1581,1070 -2695,1179 -149,15 -706,27 -855,19 z" + id="path4" /> + <path + d="m 3980,2905 c -340,-52 -607,-191 -851,-442 -293,-302 -427,-693 -390,-1135 20,-238 60,-388 153,-570 131,-256 353,-465 642,-604 164,-78 282,-113 470,-139 305,-42 608,8 877,143 339,171 584,439 700,767 111,317 116,701 12,1020 -68,210 -196,409 -369,575 -226,217 -468,336 -789,386 -110,17 -340,16 -455,-1 z" + id="path6" /> + </g> +</svg> diff --git a/variants/Chakart/class.js b/variants/Chakart/class.js index a9b1908..c987649 100644 --- a/variants/Chakart/class.js +++ b/variants/Chakart/class.js @@ -64,10 +64,6 @@ export default class ChakartRules extends ChessRules { }; } - static get INVISIBLE_QUEEN() { - return 'i'; - } - // Fictive color 'a', bomb banana mushroom egg static get BOMB() { return 'w'; //"Wario" @@ -101,6 +97,7 @@ export default class ChakartRules extends ChessRules { pieces(color, x, y) { const specials = { 'i': {"class": "invisible"}, //queen + '?': {"class": "mystery"}, //...initial square 'e': {"class": "egg"}, 'm': {"class": "mushroom"}, 'd': {"class": "banana"}, @@ -182,11 +179,7 @@ export default class ChakartRules extends ChessRules { for (let j = 0; j < this.size.y; j++) { const pieceIJ = this.getPiece(i, j); const colIJ = this.getColor(i, j); - if ( - this.board[i][j] == "" || - colIJ == 'a' || - pieceIJ == V.INVISIBLE_QUEEN - ) { + if (this.board[i][j] == "" || colIJ == 'a' || pieceIJ == 'i') { let m = new Move({ start: {x: c, y: p}, appear: [new PiPo({x: i, y: j, c: c, p: p})], @@ -272,7 +265,8 @@ export default class ChakartRules extends ChessRules { canStepOver(i, j) { return ( this.board[i][j] == "" || - [V.MUSHROOM, V.EGG].includes(this.getPiece(i, j))); + ['i', V.EGG, V.MUSHROOM].includes(this.getPiece(i, j)) + ); } getPawnMovesFrom([x, y]) { @@ -281,18 +275,20 @@ export default class ChakartRules extends ChessRules { const shiftX = (color == 'w' ? -1 : 1); const firstRank = (color == "w" ? this.size.x - 1 : 0); let moves = []; + const frontPiece = this.getPiece(x + shiftX, y); if ( this.board[x + shiftX][y] == "" || this.getColor(x + shiftX, y) == 'a' || - this.getPiece(x + shiftX, y) == V.INVISIBLE_QUEEN + frontPiece == 'i' ) { moves.push(this.getBasicMove([x, y], [x + shiftX, y])); if ( [firstRank, firstRank + shiftX].includes(x) && + ![V.BANANA, V.BOMB].includes(frontPiece) && ( this.board[x + 2 * shiftX][y] == "" || this.getColor(x + 2 * shiftX, y) == 'a' || - this.getPiece(x + 2 * shiftX, y) == V.INVISIBLE_QUEEN + this.getPiece(x + 2 * shiftX, y) == 'i' ) ) { moves.push(this.getBasicMove([x, y], [x + 2 * shiftX, y])); @@ -304,7 +300,7 @@ export default class ChakartRules extends ChessRules { y + shiftY < this.size.y && this.board[x + shiftX][y + shiftY] != "" && // Pawns cannot capture invisible queen this way! - this.getPiece(x + shiftX, y + shiftY) != V.INVISIBLE_QUEEN && + this.getPiece(x + shiftX, y + shiftY) != 'i' && ['a', oppCol].includes(this.getColor(x + shiftX, y + shiftY)) ) { moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY])); @@ -351,7 +347,7 @@ export default class ChakartRules extends ChessRules { m.vanish[0].c != 'a' ) { let im = JSON.parse(JSON.stringify(m)); - im.appear[0].p = V.INVISIBLE_QUEEN; + im.appear[0].p = 'i'; im.noAnimate = true; invisibleMoves.push(im); } @@ -366,17 +362,7 @@ export default class ChakartRules extends ChessRules { if (this.powerFlags[this.turn]['k']) { super.pieces()['k'].moves[0].steps.forEach(step => { let [i, j] = [x + step[0], y + step[1]]; - while ( - this.onBoard(i, j) && - ( - this.board[i][j] == "" || - this.getPiece(i, j) == V.INVISIBLE_QUEEN || - ( - this.getColor(i, j) == 'a' && - [V.EGG, V.MUSHROOM].includes(this.getPiece(i, j)) - ) - ) - ) { + while (this.onBoard(i, j) && this.canStepOver(i, j)) { i += step[0]; j += step[1]; } @@ -471,10 +457,12 @@ export default class ChakartRules extends ChessRules { } if (move.shell) this.powerFlags[color]['k'] = false; - else if (move.appear.length > 0 && move.appear[0].p == V.INVISIBLE_QUEEN) { + else if (move.appear.length > 0 && move.appear[0].p == 'i') { this.powerFlags[move.appear[0].c]['q'] = false; - if (color != this.playerColor) - alert("Invisible queen!"); + if (color == this.playerColor) { + move.appear.push( + new PiPo({x: move.start.x, y: move.start.y, c: color, p: '?'})); + } } if (color == this.playerColor) { // Look for an immobilized piece of my color: it can now move @@ -501,15 +489,15 @@ export default class ChakartRules extends ChessRules { for (let j=0; j<8; j++) { if ( this.board[i][j] != "" && - this.getColor(i, j) == oppCol && - this.getPiece(i, j) == V.INVISIBLE_QUEEN + this.getColor(i, j) == oppCol ) { - move.vanish.push(new PiPo({ - x: i, y: j, c: oppCol, p: V.INVISIBLE_QUEEN - })); - move.appear.push(new PiPo({ - x: i, y: j, c: oppCol, p: 'q' - })); + const pieceIJ = this.getPiece(i, j); + if (pieceIJ == 'i') { + move.vanish.push(new PiPo({x: i, y: j, c: oppCol, p: 'i'})); + move.appear.push(new PiPo({x: i, y: j, c: oppCol, p: 'q'})); + } + else if (pieceIJ == '?') + move.vanish.push(new PiPo({x: i, y: j, c: oppCol, p: '?'})); } } } @@ -519,7 +507,7 @@ export default class ChakartRules extends ChessRules { this.movesCount++; } if (move.egg) - this.displayBonus(move.egg); + this.displayBonus(move); this.playOnBoard(move); this.nextMove = move.next; } @@ -616,6 +604,7 @@ export default class ChakartRules extends ChessRules { p: this.getPiece(move.start.x, move.start.y) })); } + em.koopa = true; //to cancel mushroom effect break; case "chomp": // Eat piece @@ -636,6 +625,8 @@ export default class ChakartRules extends ChessRules { } getMushroomEffect(move) { + if (move.koopa) + return null; let step = [move.end.x - move.start.x, move.end.y - move.start.y]; if ([0, 1].some(i => Math.abs(step[i]) >= 2 && Math.abs(step[1-i]) != 1)) { // Slider, multi-squares: normalize step @@ -678,8 +669,13 @@ export default class ChakartRules extends ChessRules { return res; } - displayBonus(egg) { - alert(egg); //TODO: nicer display + displayBonus(move) { + let divBonus = document.createElement("div"); + divBonus.classList.add("bonus-text"); + divBonus.innerHTML = move.egg; + let container = document.getElementById(this.containerId); + container.appendChild(divBonus); + setTimeout(() => container.removeChild(divBonus), 2000); } atLeastOneMove() { diff --git a/variants/Chakart/style.css b/variants/Chakart/style.css index 65a44fb..b3687ce 100644 --- a/variants/Chakart/style.css +++ b/variants/Chakart/style.css @@ -31,3 +31,28 @@ piece.immobilized { piece.remote-capture { background-image: url('/pieces/chakart_shell.svg'); } + +piece.mystery.white { + background-image: url('/pieces/chakart_mystery_white.svg'); +} +piece.mystery.black { + background-image: url('/pieces/chakart_mystery_black.svg'); +} + +div.bonus-text { + position: relative; + margin-top: 5%; + width: 100%; + text-align: center; + background-color: transparent; + color: darkred; + font-weight: bold; + font-size: 2em; + animation: blinker 0.5s linear infinite; +} + +@keyframes blinker { + 50% { + opacity: 0; + } +}