projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix Parachute, allow 3 squares in Ball variant
[vchess.git]
/
client
/
src
/
variants
/
Ball.js
diff --git
a/client/src/variants/Ball.js
b/client/src/variants/Ball.js
index
85e33e6
..
3903e2b
100644
(file)
--- a/
client/src/variants/Ball.js
+++ b/
client/src/variants/Ball.js
@@
-7,7
+7,7
@@
export class BallRules extends ChessRules {
return Object.assign(
{},
ChessRules.PawnSpecs,
return Object.assign(
{},
ChessRules.PawnSpecs,
- { promotions: ChessRules.PawnSpecs.promotions.concat([V.
CHAMPION
]) }
+ { promotions: ChessRules.PawnSpecs.promotions.concat([V.
PHOENIX
]) }
);
}
);
}
@@
-15,8
+15,8
@@
export class BallRules extends ChessRules {
return false;
}
return false;
}
- static get
CHAMPION
() {
- return '
c
';
+ static get
PHOENIX
() {
+ return '
h
';
}
static get BALL() {
}
static get BALL() {
@@
-38,7
+38,7
@@
export class BallRules extends ChessRules {
'b': 'd',
'q': 't',
'k': 'l',
'b': 'd',
'q': 't',
'k': 'l',
- '
c': 'h
'
+ '
h': 'i
'
};
}
};
}
@@
-50,13
+50,13
@@
export class BallRules extends ChessRules {
'd': 'b',
't': 'q',
'l': 'k',
'd': 'b',
't': 'q',
'l': 'k',
- '
h': 'c
'
+ '
i': 'h
'
};
}
static get PIECES() {
return ChessRules.PIECES
};
}
static get PIECES() {
return ChessRules.PIECES
- .concat([V.
CHAMPION
])
+ .concat([V.
PHOENIX
])
.concat(Object.keys(V.HAS_BALL_DECODE))
.concat(['a']);
}
.concat(Object.keys(V.HAS_BALL_DECODE))
.concat(['a']);
}
@@
-105,7
+105,7
@@
export class BallRules extends ChessRules {
let prefix = "";
const withPrefix =
Object.keys(V.HAS_BALL_DECODE)
let prefix = "";
const withPrefix =
Object.keys(V.HAS_BALL_DECODE)
- .concat([V.
CHAMPION
])
+ .concat([V.
PHOENIX
])
.concat(['a']);
if (withPrefix.includes(b[1])) prefix = "Ball/";
return prefix + b;
.concat(['a']);
if (withPrefix.includes(b[1])) prefix = "Ball/";
return prefix + b;
@@
-125,7
+125,7
@@
export class BallRules extends ChessRules {
static GenRandInitFen(randomness) {
if (randomness == 0)
static GenRandInitFen(randomness) {
if (randomness == 0)
- return "
rnbcqcnbr/ppppppppp/9/9/4a4/9/9/PPPPPPPPP/RNBCQCNBR
w 0 -";
+ return "
hbnrqrnhb/ppppppppp/9/9/4a4/9/9/PPPPPPPPP/HBNRQRNHB
w 0 -";
let pieces = { w: new Array(9), b: new Array(9) };
for (let c of ["w", "b"]) {
let pieces = { w: new Array(9), b: new Array(9) };
for (let c of ["w", "b"]) {
@@
-134,17
+134,26
@@
export class BallRules extends ChessRules {
break;
}
break;
}
- // Get random squares for every piece, totally freely
+ // Get random squares for every piece, with bishops and phoenixes
+ // on different colors:
let positions = shuffle(ArrayFun.range(9));
let positions = shuffle(ArrayFun.range(9));
- const composition = ['b', 'b', '
r', 'r', 'n', 'n', 'c', 'c
', 'q'];
-
cons
t rem2 = positions[0] % 2;
+ const composition = ['b', 'b', '
h', 'h', 'n', 'n', 'r', 'r
', 'q'];
+
le
t rem2 = positions[0] % 2;
if (rem2 == positions[1] % 2) {
// Fix bishops (on different colors)
if (rem2 == positions[1] % 2) {
// Fix bishops (on different colors)
- for (let i=
2
; i<9; i++) {
+ for (let i=
4
; i<9; i++) {
if (positions[i] % 2 != rem2)
[positions[1], positions[i]] = [positions[i], positions[1]];
}
}
if (positions[i] % 2 != rem2)
[positions[1], positions[i]] = [positions[i], positions[1]];
}
}
+ rem2 = positions[2] % 2;
+ if (rem2 == positions[3] % 2) {
+ // Fix phoenixes too:
+ for (let i=4; i<9; i++) {
+ if (positions[i] % 2 != rem2)
+ [positions[3], positions[i]] = [positions[i], positions[3]];
+ }
+ }
for (let i = 0; i < 9; i++) pieces[c][positions[i]] = composition[i];
}
return (
for (let i = 0; i < 9; i++) pieces[c][positions[i]] = composition[i];
}
return (
@@
-173,16
+182,12
@@
export class BallRules extends ChessRules {
return Object.assign(
{},
ChessRules.steps,
return Object.assign(
{},
ChessRules.steps,
- // Add
champion
moves
+ // Add
phoenix
moves
{
{
-
c
: [
+
h
: [
[-2, -2],
[-2, -2],
- [-2, 0],
[-2, 2],
[-2, 2],
- [0, -2],
- [0, 2],
[2, -2],
[2, -2],
- [2, 0],
[2, 2],
[-1, 0],
[1, 0],
[2, 2],
[-1, 0],
[1, 0],
@@
-258,12
+263,12
@@
export class BallRules extends ChessRules {
// So base implementation is fine.
getPotentialMovesFrom([x, y]) {
// So base implementation is fine.
getPotentialMovesFrom([x, y]) {
- if (this.getPiece(x, y) == V.
CHAMPION
)
- return this.getPotential
Champion
Moves([x, y]);
+ if (this.getPiece(x, y) == V.
PHOENIX
)
+ return this.getPotential
Phoenix
Moves([x, y]);
return super.getPotentialMovesFrom([x, y]);
}
return super.getPotentialMovesFrom([x, y]);
}
- // "Sliders": at most
2
steps
+ // "Sliders": at most
3
steps
getSlideNJumpMoves([x, y], steps, oneStep) {
let moves = [];
outerLoop: for (let step of steps) {
getSlideNJumpMoves([x, y], steps, oneStep) {
let moves = [];
outerLoop: for (let step of steps) {
@@
-272,7
+277,7
@@
export class BallRules extends ChessRules {
let stepCount = 1;
while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) {
moves.push(this.getBasicMove([x, y], [i, j]));
let stepCount = 1;
while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) {
moves.push(this.getBasicMove([x, y], [i, j]));
- if (oneStep || stepCount ==
2
) continue outerLoop;
+ if (oneStep || stepCount ==
3
) continue outerLoop;
i += step[0];
j += step[1];
stepCount++;
i += step[0];
j += step[1];
stepCount++;
@@
-283,8
+288,8
@@
export class BallRules extends ChessRules {
return moves;
}
return moves;
}
- getPotential
Champion
Moves(sq) {
- return this.getSlideNJumpMoves(sq, V.steps[V.
CHAMPION
], "oneStep");
+ getPotential
Phoenix
Moves(sq) {
+ return this.getSlideNJumpMoves(sq, V.steps[V.
PHOENIX
], "oneStep");
}
filterValid(moves) {
}
filterValid(moves) {
@@
-321,10
+326,10
@@
export class BallRules extends ChessRules {
return {
p: 1,
r: 3,
return {
p: 1,
r: 3,
- n:
4
,
+ n:
3
,
b: 2,
q: 5,
b: 2,
q: 5,
-
c: 4
,
+
h: 3
,
a: 0 //ball: neutral
};
}
a: 0 //ball: neutral
};
}