Detect replay mode?

Game development with Board Game Arena Studio
Post Reply
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Detect replay mode?

Post 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);
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: Detect replay mode?

Post by Victoria_La »

Code: Select all

          if (typeof g_replayFrom != "undefined") {
                console.log("reply on");
                return;
            }
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Re: Detect replay mode?

Post 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';
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: Detect replay mode?

Post 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;
            }
            
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Re: Detect replay mode?

Post by quietmint »

instantaneousMode is set to false in both live and replay cases.
User avatar
quietmint
Posts: 265
Joined: 31 July 2017, 00:28

Re: Detect replay mode?

Post 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
Post Reply

Return to “Developers”