Reorganize folders (untested Baroque). Draft Go
[xogo.git] / base_rules.js
index 88197ea..4627eb7 100644 (file)
@@ -1341,7 +1341,13 @@ export default class ChessRules {
   }
 
   getStepSpec(color, x, y, piece) {
-    return this.pieces(color, x, y)[piece || this.getPieceType(x, y)];
+    let pieceType = piece;
+    const allSpecs = this.pieces(color, x, y);
+    if (!piece)
+      pieceType = this.getPieceType(x, y);
+    else if (allSpecs[piece].moveas)
+      pieceType = allSpecs[piece].moveas;
+    return allSpecs[pieceType];
   }
 
   // Can thing on square1 capture thing on square2?
@@ -2340,14 +2346,13 @@ export default class ChessRules {
   }
 
   postPlay(move) {
-    const color = this.turn;
     if (this.options["dark"])
       this.updateEnlightened();
     if (this.options["teleport"]) {
       if (
         this.subTurnTeleport == 1 &&
         move.vanish.length > move.appear.length &&
-        move.vanish[1].c == color
+        move.vanish[1].c == this.turn
       ) {
         const v = move.vanish[move.vanish.length - 1];
         this.captured = {x: v.x, y: v.y, c: v.c, p: v.p};
@@ -2362,7 +2367,7 @@ export default class ChessRules {
 
   tryChangeTurn(move) {
     if (this.isLastMove(move)) {
-      this.turn = C.GetOppCol(color);
+      this.turn = C.GetOppCol(this.turn);
       this.movesCount++;
       this.subTurn = 1;
     }