X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=public%2Fjavascripts%2Fbase_rules.js;h=6bc3591cfc601c3604a4f7c7f7f0619db8c5b553;hb=8a60cacd26d8c47f52ecac26091d6a6f65e6bbc5;hp=360f60c53487bb49210ad5ad2d406593d93e7505;hpb=1221ac47836806efb287b0323b92957d9129c653;p=vchess.git
diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js
index 360f60c5..6bc3591c 100644
--- a/public/javascripts/base_rules.js
+++ b/public/javascripts/base_rules.js
@@ -724,9 +724,11 @@ class ChessRules
// DEBUG:
// if (!this.states) this.states = [];
// if (!ingame) this.states.push(JSON.stringify(this.board));
+// if (!this.rstates) this.rstates = [];
+// if (!ingame) this.rstates.push(JSON.stringify(this.promoted)+"-"+JSON.stringify(this.reserve));
if (!!ingame)
- move.notation = this.getNotation(move);
+ move.notation = [this.getNotation(move), this.getLongNotation(move)];
move.flags = JSON.stringify(this.flags); //save flags (for undo)
this.updateVariables(move);
@@ -745,7 +747,8 @@ class ChessRules
// DEBUG:
// let state = this.states.pop();
-// if (JSON.stringify(this.board) != state)
+// let rstate = this.rstates.pop();
+// if (JSON.stringify(this.board) != state || JSON.stringify(this.promoted)+"-"+JSON.stringify(this.reserve) != rstate)
// debugger;
}
@@ -1110,6 +1113,16 @@ class ChessRules
}
}
+ // Complete the usual notation, may be required for de-ambiguification
+ getLongNotation(move)
+ {
+ const startSquare =
+ 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);
+ return startSquare + finalSquare; //not encoding move. But short+long is enough
+ }
+
// The score is already computed when calling this function
getPGN(mycolor, score, fenStart, mode)
{
@@ -1124,14 +1137,24 @@ class ChessRules
pgn += '[Fen "' + fenStart + '"]
';
pgn += '[Result "' + score + '"]
';
+ // Standard PGN
for (let i=0; i
";
+ // "Complete moves" PGN (helping in ambiguous cases)
+ for (let i=0; i