X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FHorde.js;h=a54b50924519fe148ca056804058e64d5785963c;hb=HEAD;hp=e61803b3d480664419134da6c880779caa5ed7e0;hpb=f9385686d9434c607cdaa55e41a0425269db0815;p=vchess.git diff --git a/client/src/variants/Horde.js b/client/src/variants/Horde.js index e61803b3..a54b5092 100644 --- a/client/src/variants/Horde.js +++ b/client/src/variants/Horde.js @@ -1,6 +1,19 @@ import { ChessRules } from "@/base_rules"; export class HordeRules extends ChessRules { + + static get Options() { + return { + check: [ + { + label: "Random", + defaut: false, + variable: "random" + } + ] + }; + } + static get HasFlags() { return false; } @@ -24,7 +37,7 @@ export class HordeRules extends ChessRules { } sumElts++; } else { - const num = parseInt(row[i]); + const num = parseInt(row[i], 10); if (isNaN(num)) return false; sumElts += num; } @@ -35,17 +48,31 @@ export class HordeRules extends ChessRules { return true; } - static GenRandInitFen(randomness) { - if (randomness == 2) randomness--; - const fen = ChessRules.GenRandInitFen(randomness); + static GenRandInitFen(options) { + const fen = + ChessRules.GenRandInitFen({ randomness: (options.random ? 1 : 0) }); return ( - // 27 first chars are 3 rows + 3 slashes - fen.substr(0, 27) + // 20 first chars are 3 rows + 3 slashes + fen.substr(0, 20) // En passant available, but no castle: .concat("1PP2PP1/PPPPPPPP/PPPPPPPP/PPPPPPPP/PPPPPPPP w 0 -") ); } + filterValid(moves) { + if (this.turn == 'w') return moves; + return super.filterValid(moves); + } + + getCheckSquares() { + if (this.turn == 'w') return []; + return ( + this.underCheck('b') + ? [JSON.parse(JSON.stringify(this.kingPos['b']))] + : [] + ); + } + getCurrentScore() { if (this.turn == 'w') { // Do I have any unit remaining? If not, I lost. @@ -66,4 +93,5 @@ export class HordeRules extends ChessRules { // From black side, just run usual checks: return super.getCurrentScore(); } + };