Ultima bug: mate in 1 does not mate...
[vchess.git] / public / javascripts / variants / Ultima.js
index d5b9f88..229910c 100644 (file)
@@ -445,6 +445,7 @@ class UltimaRules extends ChessRules
                                for (let j=0; j<sizeY; j++)
                                {
                                        if (this.board[i][j] != VariantRules.EMPTY
+                                               && colors.includes(this.getColor(i,j))
                                                && this.getPiece(i,j) == VariantRules.ROOK)
                                        {
                                                if (this.isImmobilized([i,j]))
@@ -623,4 +624,25 @@ class UltimaRules extends ChessRules
        {
                return "0000"; //TODO: or "-" ?
        }
+
+       getNotation(move)
+       {
+               const initialSquare =
+                       String.fromCharCode(97 + move.start.y) + (VariantRules.size[0]-move.start.x);
+               const finalSquare =
+                       String.fromCharCode(97 + move.end.y) + (VariantRules.size[0]-move.end.x);
+               let notation = undefined;
+               if (move.appear[0].p == VariantRules.PAWN)
+               {
+                       // Pawn: generally ambiguous short notation, so we use full description
+                       notation = "P" + initialSquare + finalSquare;
+               }
+               else if (move.appear[0].p == VariantRules.KING)
+                       notation = "K" + (move.vanish.length>1 ? "x" : "") + finalSquare;
+               else
+                       notation = move.appear[0].p.toUpperCase() + finalSquare;
+               if (move.vanish.length > 1 && move.appear[0].p != VariantRules.KING)
+                       notation += "X"; //capture mark (not describing what is captured...)
+               return notation;
+       }
 }