X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=variants%2FCrossing%2Fclass.js;fp=variants%2FCrossing%2Fclass.js;h=75665a541a0ce9e3c816ceba1697b4ceaea09026;hp=0000000000000000000000000000000000000000;hb=7379efc5a40788dbf093a4dd5613ca9fbe73cbcf;hpb=8f87962339f2bcaeb4c2716d0588a63449a68bde diff --git a/variants/Crossing/class.js b/variants/Crossing/class.js new file mode 100644 index 0000000..75665a5 --- /dev/null +++ b/variants/Crossing/class.js @@ -0,0 +1,34 @@ +import ChessRules from "/base_rules.js"; + +export default class CrossingRules extends ChessRules { + + getSvgChessboard() { + let svg = super.getSvgChessboard(); + return ( + svg.slice(0, -6) + + '' + ); + } + + getCurrentScore(move_s) { + const res = super.getCurrentScore(move_s); + if (res != "*") + return res; + // Turn has changed: + const color = V.GetOppTurn(this.turn); + const secondHalf = (color == 'w' ? [0, 1, 2, 3] : [4, 5, 6, 7]); + for (let move of move_s) { + if ( + move.appear.length >= 1 && + move.appear[0].p == 'k' && + secondHalf.includes(move.appear[0].x) + ) { + // Half-board is crossed + return color == "w" ? "1-0" : "0-1"; + } + } + return "*"; + } + +};