Simplified underCheck / getCheckSquares logic. Debugging Berolina
[vchess.git] / public / javascripts / variants / Upsidedown.js
CommitLineData
f6dbe8e3 1class UpsidedownRules extends ChessRules
388e4c40
BA
2{
3 static HasFlags() { return false; }
4
f6dbe8e3
BA
5 // Forbid two knights moves in a row at moves 1 and 2
6 getPotentialKnightMoves(sq)
7 {
8 // But this will also affect FEN for problems, and...
9 // does it really solve the problem ?
10 //if (this.moves. ...)
11 }
12
388e4c40
BA
13 getPotentialKingMoves(sq)
14 {
15 // No castle
16 return this.getSlideNJumpMoves(sq,
17 V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep");
18 }
19
20 static GenRandInitFen()
21 {
22 let pieces = { "w": new Array(8), "b": new Array(8) };
23 for (let c of ["w","b"])
24 {
25 let positions = _.range(8);
26
27 let randIndex = 2 * _.random(3);
28 let bishop1Pos = positions[randIndex];
29 let randIndex_tmp = 2 * _.random(3) + 1;
30 let bishop2Pos = positions[randIndex_tmp];
31 positions.splice(Math.max(randIndex,randIndex_tmp), 1);
32 positions.splice(Math.min(randIndex,randIndex_tmp), 1);
33
34 randIndex = _.random(5);
35 let knight1Pos = positions[randIndex];
36 positions.splice(randIndex, 1);
37 randIndex = _.random(4);
38 let knight2Pos = positions[randIndex];
39 positions.splice(randIndex, 1);
40
41 randIndex = _.random(3);
42 let queenPos = positions[randIndex];
43 positions.splice(randIndex, 1);
44
45 let rook1Pos = positions[0];
46 let kingPos = positions[1];
47 let rook2Pos = positions[2];
48
49 pieces[c][rook1Pos] = 'r';
50 pieces[c][knight1Pos] = 'n';
51 pieces[c][bishop1Pos] = 'b';
52 pieces[c][queenPos] = 'q';
53 pieces[c][kingPos] = 'k';
54 pieces[c][bishop2Pos] = 'b';
55 pieces[c][knight2Pos] = 'n';
56 pieces[c][rook2Pos] = 'r';
57 }
f6dbe8e3 58 return pieces["w"].join("").toUpperCase() +
388e4c40 59 "/PPPPPPPP/8/8/8/8/pppppppp/" +
f6dbe8e3 60 pieces["b"].join("") +
388e4c40
BA
61 " w 1111 -"; //add turn + flags + enpassant
62 }
63}
64
65const VariantRules = UpsidedownRules;