projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some debug, plan several short + long term TODOs
[vchess.git]
/
public
/
javascripts
/
variants
/
Switching.js
diff --git
a/public/javascripts/variants/Switching.js
b/public/javascripts/variants/Switching.js
index
e53ab69
..
67078f5
100644
(file)
--- a/
public/javascripts/variants/Switching.js
+++ b/
public/javascripts/variants/Switching.js
@@
-104,7
+104,7
@@
class SwitchingRules extends ChessRules
&& move.appear[1].p == V.KING)
{
// Switch with the king; not castle, and not handled by main class
&& move.appear[1].p == V.KING)
{
// Switch with the king; not castle, and not handled by main class
- const color =
this.getColor(move.start.x, move.start.y)
;
+ const color =
move.vanish[0].c
;
this.kingPos[color] = [move.appear[1].x, move.appear[1].y];
}
}
this.kingPos[color] = [move.appear[1].x, move.appear[1].y];
}
}
@@
-115,7
+115,7
@@
class SwitchingRules extends ChessRules
if (move.appear.length == 2 && move.vanish.length == 2
&& move.appear[1].p == V.KING)
{
if (move.appear.length == 2 && move.vanish.length == 2
&& move.appear[1].p == V.KING)
{
- const color =
this.getColor(move.start.x, move.start.y)
;
+ const color =
move.vanish[0].c
;
this.kingPos[color] = [move.appear[0].x, move.appear[0].y];
}
}
this.kingPos[color] = [move.appear[0].x, move.appear[0].y];
}
}
@@
-130,11
+130,7
@@
class SwitchingRules extends ChessRules
if (move.appear[0].p == V.KING && move.appear[1].p == V.ROOK)
return (move.end.y < move.start.y ? "0-0-0" : "0-0");
// Switch:
if (move.appear[0].p == V.KING && move.appear[1].p == V.ROOK)
return (move.end.y < move.start.y ? "0-0-0" : "0-0");
// Switch:
- const startSquare =
- String.fromCharCode(97 + move.start.y) + (V.size.x-move.start.x);
- const finalSquare =
- String.fromCharCode(97 + move.end.y) + (V.size.x-move.end.x);
- return "S" + startSquare + finalSquare;
+ return "S" + V.CoordsToSquare(move.start) + V.CoordsToSquare(move.end);
}
}
}
}