Page 1 of 1
Detect replay mode?
Posted: 29 November 2017, 03:43
by quietmint
In JavaScript side, is there a way to detect that the game is in replay mode? For example, I do not want to run this code which starts a timer unless the game is really active.
Code: Select all
onUpdateActionButtons: function(stateName, args) {
console.log('Update action buttons: ' + stateName, args);
if (this.isCurrentPlayerActive()) {
var timer = setInterval( ... , 1000);
Re: Detect replay mode?
Posted: 30 November 2017, 13:34
by Victoria_La
Code: Select all
if (typeof g_replayFrom != "undefined") {
console.log("reply on");
return;
}
Re: Detect replay mode?
Posted: 07 January 2018, 07:15
by quietmint
Thanks Victoria. It appears there are two different replay modes, "Replay from this move" -- which sets
g_replayFrom global variable -- and "Replay last turn" -- which does not.
Instead, I used this approach which detects both:
Code: Select all
var isReplay = document.getElementById('previously_on').style.display == 'block';
Re: Detect replay mode?
Posted: 07 January 2018, 17:40
by Victoria_La
quietmint wrote:Thanks Victoria. It appears there are two different replay modes, "Replay from this move" -- which sets
g_replayFrom global variable -- and "Replay last turn" -- which does not.
Instead, I used this approach which detects both:
Code: Select all
var isReplay = document.getElementById('previously_on').style.display == 'block';
That seems to be more hacky... What is this.game.instantaneousMode set to in this case?
Maybe it just
Code: Select all
if (typeof g_replayFrom != "undefined" || this.game.instantaneousMode ) {
console.log("reply on");
return;
}
Re: Detect replay mode?
Posted: 08 January 2018, 01:41
by quietmint
instantaneousMode is set to false in both live and replay cases.
Re: Detect replay mode?
Posted: 08 July 2020, 04:22
by quietmint
These seem to be the two variables to check:
Code: Select all
var isInstantReplay = typeof g_replayFrom != "undefined"; // during the game
var isArchiveReplay = g_archive_mode; // after game has ended