X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FShinobi.js;h=e993188b33ecce697bf141dd5ccf7a84a9e915d8;hb=4313762da3237b04f204e121a20cab3ba7bb5dd2;hp=dbce82c87e976fbcf6c60564b99a2c57e086ddf4;hpb=b0116a67818668f55cd2a3b3a323b2c91b5bc332;p=vchess.git diff --git a/client/src/variants/Shinobi.js b/client/src/variants/Shinobi.js index dbce82c8..e993188b 100644 --- a/client/src/variants/Shinobi.js +++ b/client/src/variants/Shinobi.js @@ -60,7 +60,7 @@ export class ShinobiRules extends ChessRules { if (!ChessRules.IsGoodFen(fen)) return false; const fenParsed = V.ParseFen(fen); // 5) Check reserve - if (!fenParsed.reserve || !fenParsed.reserve.match(/^[0-2]{6,6}$/)) + if (!fenParsed.reserve || !fenParsed.reserve.match(/^[0-2]{5,5}$/)) return false; return true; } @@ -74,12 +74,14 @@ export class ShinobiRules extends ChessRules { } // In hand initially: ninja, dragon, 2 x (monk, horse), lance, pawn. - static GenRandInitFen(randomness) { - const baseFen = ChessRules.GenRandInitFen(Math.min(randomness, 1)); - return ( - baseFen.substr(0, 35) + "3CK3 " + - "w 0 " + baseFen.substr(48, 2) + " - 112211" - ); + static GenRandInitFen(options) { + const baseFen = ChessRules.GenRandInitFen(options); + const position = baseFen.substr(0, 43) + .replace('Q', 'C') + .replace(/B/g, '1') + .replace(/R/g, 'L') + .replace(/N/g, 'H'); + return position + " w 0 " + baseFen.substr(48, 2) + " - 11211"; } getFen() { @@ -105,8 +107,7 @@ export class ShinobiRules extends ChessRules { [V.DRAGON]: reserve[1], [V.MONK]: reserve[2], [V.HORSE]: reserve[3], - [V.LANCE]: reserve[4], - [V.PAWN]: reserve[5] + [V.LANCE]: reserve[4] } }; } @@ -122,7 +123,7 @@ export class ShinobiRules extends ChessRules { } static get RESERVE_PIECES() { - return [V.NINJA, V.DRAGON, V.MONK, V.HORSE, V.LANCE, V.PAWN]; + return [V.NINJA, V.DRAGON, V.MONK, V.HORSE, V.LANCE]; } getReserveMoves([x, y]) { @@ -207,37 +208,34 @@ export class ShinobiRules extends ChessRules { if (this.getColor(x, y) == 'b') return super.getPotentialKingMoves([x, y]); // Clan doesn't castle: return super.getSlideNJumpMoves( - [x, y], - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ); + [x, y], V.steps[V.ROOK].concat(V.steps[V.BISHOP]), 1); } getPotentialCaptainMoves(sq) { const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]); - return super.getSlideNJumpMoves(sq, steps, "oneStep"); + return super.getSlideNJumpMoves(sq, steps, 1); } getPotentialNinjaMoves(sq) { return ( super.getSlideNJumpMoves(sq, V.steps[V.BISHOP]) - .concat(super.getSlideNJumpMoves(sq, V.steps[V.KNIGHT], "oneStep")) + .concat(super.getSlideNJumpMoves(sq, V.steps[V.KNIGHT], 1)) ); } getPotentialDragonMoves(sq) { return ( super.getSlideNJumpMoves(sq, V.steps[V.ROOK]) - .concat(super.getSlideNJumpMoves(sq, V.steps[V.BISHOP], "oneStep")) + .concat(super.getSlideNJumpMoves(sq, V.steps[V.BISHOP], 1)) ); } getPotentialMonkMoves(sq) { - return super.getSlideNJumpMoves(sq, V.steps[V.BISHOP], "oneStep"); + return super.getSlideNJumpMoves(sq, V.steps[V.BISHOP], 1); } getPotentialHorseMoves(sq) { - return super.getSlideNJumpMoves(sq, [ [-2, 1], [-2, -1] ], "oneStep"); + return super.getSlideNJumpMoves(sq, [ [-2, 1], [-2, -1] ], 1); } getPotentialLanceMoves(sq) { @@ -266,7 +264,7 @@ export class ShinobiRules extends ChessRules { isAttackedByCaptain(sq, color) { const steps = V.steps[V.BISHOP].concat(V.steps[V.ROOK]); return ( - super.isAttackedBySlideNJump(sq, color, V.CAPTAIN, steps, "oneStep") + super.isAttackedBySlideNJump(sq, color, V.CAPTAIN, steps, 1) ); } @@ -274,7 +272,7 @@ export class ShinobiRules extends ChessRules { return ( super.isAttackedBySlideNJump(sq, color, V.NINJA, V.steps[V.BISHOP]) || super.isAttackedBySlideNJump( - sq, color, V.NINJA, V.steps[V.KNIGHT], "oneStep") + sq, color, V.NINJA, V.steps[V.KNIGHT], 1) ); } @@ -282,21 +280,21 @@ export class ShinobiRules extends ChessRules { return ( super.isAttackedBySlideNJump(sq, color, V.DRAGON, V.steps[V.ROOK]) || super.isAttackedBySlideNJump( - sq, color, V.DRAGON, V.steps[V.BISHOP], "oneStep") + sq, color, V.DRAGON, V.steps[V.BISHOP], 1) ); } isAttackedByMonk(sq, color) { return ( super.isAttackedBySlideNJump( - sq, color, V.MONK, V.steps[V.BISHOP], "oneStep") + sq, color, V.MONK, V.steps[V.BISHOP], 1) ); } isAttackedByHorse(sq, color) { return ( super.isAttackedBySlideNJump( - sq, color, V.HORSE, [ [2, 1], [2, -1] ], "oneStep") + sq, color, V.HORSE, [ [2, 1], [2, -1] ], 1) ); } @@ -386,7 +384,7 @@ export class ShinobiRules extends ChessRules { { c: 4, j: 7, - d: 7, + d: 6, m: 2, h: 2, l: 2