projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check variants. All OK except Dark (bug), Checkered (missing internal moves stack...
[vchess.git]
/
client
/
src
/
variants
/
Upsidedown.js
diff --git
a/client/src/variants/Upsidedown.js
b/client/src/variants/Upsidedown.js
index
c3e8716
..
de72216
100644
(file)
--- a/
client/src/variants/Upsidedown.js
+++ b/
client/src/variants/Upsidedown.js
@@
-1,4
+1,8
@@
-class UpsidedownRules extends ChessRules
+import { ChessRules } from "@/base_rules";
+import { randInt } from "@/utils/alea";
+import { ArrayFun } from "@/utils/array";
+
+export const VariantRules = class UpsidedownRules extends ChessRules
{
static get HasFlags() { return false; }
{
static get HasFlags() { return false; }
@@
-16,7
+20,7
@@
class UpsidedownRules extends ChessRules
let pieces = { "w": new Array(8), "b": new Array(8) };
for (let c of ["w","b"])
{
let pieces = { "w": new Array(8), "b": new Array(8) };
for (let c of ["w","b"])
{
- let positions = range(8);
+ let positions =
ArrayFun.
range(8);
let randIndex = randInt(8);
const kingPos = positions[randIndex];
let randIndex = randInt(8);
const kingPos = positions[randIndex];
@@
-29,7
+33,7
@@
class UpsidedownRules extends ChessRules
else if (kingPos == V.size.y-1)
knight1Pos = V.size.y-2;
else
else if (kingPos == V.size.y-1)
knight1Pos = V.size.y-2;
else
- knight1Pos = kingPos + (Math.rand
Int
() < 0.5 ? 1 : -1);
+ knight1Pos = kingPos + (Math.rand
om
() < 0.5 ? 1 : -1);
// Search for knight1Pos index in positions and remove it
const knight1Index = positions.indexOf(knight1Pos);
positions.splice(knight1Index, 1);
// Search for knight1Pos index in positions and remove it
const knight1Index = positions.indexOf(knight1Pos);
positions.splice(knight1Index, 1);
@@
-65,6
+69,6
@@
class UpsidedownRules extends ChessRules
return pieces["w"].join("").toUpperCase() +
"/PPPPPPPP/8/8/8/8/pppppppp/" +
pieces["b"].join("") +
return pieces["w"].join("").toUpperCase() +
"/PPPPPPPP/8/8/8/8/pppppppp/" +
pieces["b"].join("") +
- " w"; //no castle, no en-passant
+ " w
0
"; //no castle, no en-passant
}
}
}
}