From: Benjamin Auder Date: Tue, 21 Jun 2022 17:36:14 +0000 (+0200) Subject: Add Cleopatra option to Benedict chess X-Git-Url: https://git.auder.net/images/assets/doc/html/css/parser.js?a=commitdiff_plain;h=e2be4b04faeac3fca5b292499bb70b98542e45ce;p=xogo.git Add Cleopatra option to Benedict chess --- diff --git a/pieces/Benedict/black_cleopatra.svg b/pieces/Benedict/black_cleopatra.svg new file mode 100644 index 0000000..4360044 --- /dev/null +++ b/pieces/Benedict/black_cleopatra.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/pieces/Benedict/white_cleopatra.svg b/pieces/Benedict/white_cleopatra.svg new file mode 100644 index 0000000..fd7f323 --- /dev/null +++ b/pieces/Benedict/white_cleopatra.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/variants.js b/variants.js index 90e9244..59a69c0 100644 --- a/variants.js +++ b/variants.js @@ -1,5 +1,4 @@ const variants = [ - // TODO: https://mancala.fandom.com/wiki/William_Daniel_Troyka Cleopatra chess {name: 'Absorption', desc: 'Absorb powers'}, {name: 'Alapo', desc: 'Geometric Chess'}, // {name: 'Alice', desc: 'Both sides of the mirror'}, diff --git a/variants/Benedict/CREDITS b/variants/Benedict/CREDITS new file mode 100644 index 0000000..e936f02 --- /dev/null +++ b/variants/Benedict/CREDITS @@ -0,0 +1,4 @@ +Images: + +https://game-icons.net/1x1/delapouite/cleopatra.html +https://www.svgrepo.com/svg/322047/cleopatra diff --git a/variants/Benedict/class.js b/variants/Benedict/class.js index 81fee87..2bc60e7 100644 --- a/variants/Benedict/class.js +++ b/variants/Benedict/class.js @@ -6,6 +6,14 @@ export default class BenedictRules extends ChessRules { static get Options() { return { select: C.Options.select, + input: [ + { + label: "Cleopatra", + variable: "cleopatra", + type: "checkbox", + defaut: false + } + ], styles: [ "balance", "cylinder", @@ -25,6 +33,24 @@ export default class BenedictRules extends ChessRules { return false; } + pieces(color, x, y) { + if (!this.options["cleopatra"]) + return super.pieces(color, x, y); + return Object.assign({}, super.pieces(color, x, y), { + 'q': { + "class": "cleopatra", + moves: [ + { + steps: [ + [0, 1], [0, -1], [1, 0], [-1, 0], + [1, 1], [1, -1], [-1, 1], [-1, -1] + ] + } + ] + }, + }); + } + // Find potential captures from a square // follow steps from x,y until something is met. findAttacks([x, y]) { @@ -56,20 +82,22 @@ export default class BenedictRules extends ChessRules { postProcessPotentialMoves(moves) { moves.forEach(m => { - super.playOnBoard(m); - let attacks = this.findAttacks([m.end.x, m.end.y]) - if (this.options["zen"]) { - let endSquares = {}; - super.findCapturesOn([m.end.x, m.end.y], {zen: true}).forEach(c => { - endSquares[C.CoordsToSquare(c.end)] = true; + m.flips = []; + if (!this.options["cleopatra"] || m.vanish[0].p == 'q') { + super.playOnBoard(m); + let attacks = this.findAttacks([m.end.x, m.end.y]) + if (this.options["zen"]) { + let endSquares = {}; + super.findCapturesOn([m.end.x, m.end.y], {zen: true}).forEach(c => { + endSquares[C.CoordsToSquare(c.end)] = true; + }); + Array.prototype.push.apply(attacks, Object.keys(endSquares)); + } + super.undoOnBoard(m); + attacks.map(C.SquareToCoords).forEach(a => { + m.flips.push({x: a.x, y: a.y}); }); - Array.prototype.push.apply(attacks, Object.keys(endSquares)); } - super.undoOnBoard(m); - m.flips = []; - attacks.map(C.SquareToCoords).forEach(a => { - m.flips.push({x: a.x, y: a.y}); - }); }); return moves; } diff --git a/variants/Benedict/rules.html b/variants/Benedict/rules.html index 1a21c0c..92f633e 100644 --- a/variants/Benedict/rules.html +++ b/variants/Benedict/rules.html @@ -2,4 +2,12 @@

Goal: change the enemy king's color.

+

+ The "Cleopatra" option follow + + these rules + + where only the queen can change the color of enemy pieces. +

+

William Daniel Troyka (2001).

diff --git a/variants/Benedict/style.css b/variants/Benedict/style.css index a3550bc..0923e9e 100644 --- a/variants/Benedict/style.css +++ b/variants/Benedict/style.css @@ -1 +1,9 @@ @import url("/base_pieces.css"); + +piece.black.cleopatra { + background-image: url('/pieces/Benedict/black_cleopatra.svg'); +} + +piece.white.cleopatra { + background-image: url('/pieces/Benedict/white_cleopatra.svg'); +}