projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix ExtinctionRules position check, add prev/next buttons in problems page
[vchess.git]
/
client
/
src
/
base_rules.js
diff --git
a/client/src/base_rules.js
b/client/src/base_rules.js
index
295b4cd
..
350e0de
100644
(file)
--- a/
client/src/base_rules.js
+++ b/
client/src/base_rules.js
@@
-96,9
+96,12
@@
export const ChessRules = class ChessRules {
if (position.length == 0) return false;
const rows = position.split("/");
if (rows.length != V.size.x) return false;
if (position.length == 0) return false;
const rows = position.split("/");
if (rows.length != V.size.x) return false;
+ let kings = {};
for (let row of rows) {
let sumElts = 0;
for (let i = 0; i < row.length; i++) {
for (let row of rows) {
let sumElts = 0;
for (let i = 0; i < row.length; i++) {
+ if (['K','k'].includes(row[i]))
+ kings[row[i]] = true;
if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
else {
const num = parseInt(row[i]);
if (V.PIECES.includes(row[i].toLowerCase())) sumElts++;
else {
const num = parseInt(row[i]);
@@
-108,6
+111,9
@@
export const ChessRules = class ChessRules {
}
if (sumElts != V.size.y) return false;
}
}
if (sumElts != V.size.y) return false;
}
+ // Both kings should be on board:
+ if (Object.keys(kings).length != 2)
+ return false;
return true;
}
return true;
}