- if (game.scoreMsg) game.scoreMsg = this.st.tr[game.scoreMsg]; //stored in english
- delete game["moveToPlay"]; //in case of!
+ this.repeat = {}; //reset: scan past moves' FEN:
+ let repIdx = 0;
+ // NOTE: vr_tmp to obtain FEN strings is redundant with BaseGame
+ let vr_tmp = new V(game.fenStart);
+ let movesCount = -1;
+ let curTurn = "n";
+ game.moves.forEach(m => {
+ if (vr_tmp.turn != curTurn)
+ {
+ movesCount++;
+ curTurn = vr_tmp.turn;
+ }
+ vr_tmp.play(m);
+ const fenObj = V.ParseFen(vr_tmp.getFen());
+ repIdx = fenObj.position + "_" + fenObj.turn;
+ if (fenObj.flags) repIdx += "_" + fenObj.flags;
+ this.repeat[repIdx] = this.repeat[repIdx]
+ ? this.repeat[repIdx] + 1
+ : 1;
+ });
+ if (vr_tmp.turn != curTurn)
+ movesCount++;
+ if (this.repeat[repIdx] >= 3) this.drawOffer = "threerep";