X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FBall.js;h=5de871d77c6e2611d54390f22699121e89985c37;hb=4f3a08234f754abcb74f369067f960a8269557a3;hp=056ec61b10750ee4a085e81bc9e87c57780e6715;hpb=e50a802531b99829c533f22ecd21e359e7e1e049;p=vchess.git diff --git a/client/src/variants/Ball.js b/client/src/variants/Ball.js index 056ec61b..5de871d7 100644 --- a/client/src/variants/Ball.js +++ b/client/src/variants/Ball.js @@ -3,6 +3,7 @@ import { ArrayFun } from "@/utils/array"; import { shuffle } from "@/utils/alea"; export class BallRules extends ChessRules { + static get Lines() { return [ // White goal: @@ -35,7 +36,7 @@ export class BallRules extends ChessRules { } static get BALL() { - // Ball is already taken: + // 'b' is already taken: return "aa"; } @@ -94,17 +95,18 @@ export class BallRules extends ChessRules { const rows = position.split("/"); if (rows.length != V.size.x) return false; let pieces = { "w": 0, "b": 0 }; - const withBall = Object.keys(V.HAS_BALL_DECODE).concat([V.BALL]); + const withBall = Object.keys(V.HAS_BALL_DECODE).concat(['a']); let ballCount = 0; for (let row of rows) { let sumElts = 0; for (let i = 0; i < row.length; i++) { const lowerRi = row[i].toLowerCase(); if (V.PIECES.includes(lowerRi)) { - if (lowerRi != V.BALL) pieces[row[i] == lowerRi ? "b" : "w"]++; + if (lowerRi != 'a') pieces[row[i] == lowerRi ? "b" : "w"]++; if (withBall.includes(lowerRi)) ballCount++; sumElts++; - } else { + } + else { const num = parseInt(row[i], 10); if (isNaN(num)) return false; sumElts += num; @@ -336,7 +338,8 @@ export class BallRules extends ChessRules { }) ); } - } else if (mv.vanish[1].c == mv.vanish[0].c) { + } + else if (mv.vanish[1].c == mv.vanish[0].c) { // Pass the ball: the passing unit does not disappear mv.appear.push(JSON.parse(JSON.stringify(mv.vanish[0]))); mv.appear[0].p = V.HAS_BALL_CODE[mv.vanish[1].p]; @@ -565,4 +568,5 @@ export class BallRules extends ChessRules { finalSquare ); } + };