projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prevent infinite loops for moves input in Pacosako + Otage
[vchess.git]
/
client
/
src
/
variants
/
Suicide.js
diff --git
a/client/src/variants/Suicide.js
b/client/src/variants/Suicide.js
index
c81d355
..
13aaa6b
100644
(file)
--- a/
client/src/variants/Suicide.js
+++ b/
client/src/variants/Suicide.js
@@
-3,11
+3,8
@@
import { ArrayFun } from "@/utils/array";
import { shuffle } from "@/utils/alea";
export class SuicideRules extends ChessRules {
import { shuffle } from "@/utils/alea";
export class SuicideRules extends ChessRules {
- static get HasFlags() {
- return false;
- }
- static get Has
Castle
() {
+ static get Has
Flags
() {
return false;
}
return false;
}
@@
-32,8
+29,9
@@
export class SuicideRules extends ChessRules {
if (V.PIECES.includes(lowerRi)) {
pieces[row[i] == lowerRi ? "b" : "w"]++;
sumElts++;
if (V.PIECES.includes(lowerRi)) {
pieces[row[i] == lowerRi ? "b" : "w"]++;
sumElts++;
- } else {
- const num = parseInt(row[i]);
+ }
+ else {
+ const num = parseInt(row[i], 10);
if (isNaN(num)) return false;
sumElts += num;
}
if (isNaN(num)) return false;
sumElts += num;
}
@@
-54,12
+52,11
@@
export class SuicideRules extends ChessRules {
// Stop at the first capture found (if any)
atLeastOneCapture() {
const color = this.turn;
// Stop at the first capture found (if any)
atLeastOneCapture() {
const color = this.turn;
- const oppCol = V.GetOppCol(color);
for (let i = 0; i < V.size.x; i++) {
for (let j = 0; j < V.size.y; j++) {
if (
this.board[i][j] != V.EMPTY &&
for (let i = 0; i < V.size.x; i++) {
for (let j = 0; j < V.size.y; j++) {
if (
this.board[i][j] != V.EMPTY &&
- this.getColor(i, j)
!= oppCol
&&
+ this.getColor(i, j)
== color
&&
this.getPotentialMovesFrom([i, j]).some(m => m.vanish.length == 2)
) {
return true;
this.getPotentialMovesFrom([i, j]).some(m => m.vanish.length == 2)
) {
return true;
@@
-156,8
+153,10
@@
export class SuicideRules extends ChessRules {
if (rem2 == positions[1] % 2) {
// Fix bishops (on different colors)
for (let i=2; i<8; i++) {
if (rem2 == positions[1] % 2) {
// Fix bishops (on different colors)
for (let i=2; i<8; i++) {
- if (positions[i] % 2 != rem2)
+ if (positions[i] % 2 != rem2)
{
[positions[1], positions[i]] = [positions[i], positions[1]];
[positions[1], positions[i]] = [positions[i], positions[1]];
+ break;
+ }
}
}
for (let i = 0; i < 8; i++) pieces[c][positions[i]] = composition[i];
}
}
for (let i = 0; i < 8; i++) pieces[c][positions[i]] = composition[i];
@@
-170,4
+169,5
@@
export class SuicideRules extends ChessRules {
" w 0 -"
);
}
" w 0 -"
);
}
+
};
};