Page 1 of 1

Replay of Game not working because of DB modification?

Posted: 04 September 2020, 12:21
by MikeIsHere
In the game cribbage, I have settings that the user can set on the client but update the database
(this would be similar to the Auto-Hammer in DiceForge)

When I try to replay a game after choosing the player I want to be I get the following error
ly_studio.js:2 During pageload
Cannot read property 'data' of undefined
TypeError: Cannot read property 'data' of undefined
at Object.ajaxcall (https://x.boardgamearena.net/data/theme ... s:2:639210)
at Object.setInitialPreference (https://x.boardgamearena.net/data/theme ... js:1:14271)
at Object.setup (https://x.boardgamearena.net/data/theme ... .js:1:8742)
at Object.completesetup (https://x.boardgamearena.net/data/theme ... s:2:572801)
at https://boardgamearena.com/archive/repl ... 8;:2196:24
at _ce (https://x.boardgamearena.net/data/theme ... js:8:12390)
at _37 (https://x.boardgamearena.net/data/theme ... js:8:14010)
at https://x.boardgamearena.net/data/theme ... js:8:14274
at _38 (https://x.boardgamearena.net/data/theme ... js:8:14100)
at _81 (https://x.boardgamearena.net/data/theme ... js:8:14199)
The method setInitialPreferences is this

Code: Select all

setInitialPreference: function (action, autoGo, autoCut) {
	this.ajaxcall("/" + this.game_name + "/" + this.game_name + "/" + action +".html", {
		autoGo: autoGo,
		autoCut: autoCut,
		lock: true
	}, this, function (result) { 
		console.log(result);
	}, function (is_error) {
		console.log(is_error);
	});
},
Basically it sets two boolean columns in the DB that the server then uses to determine if it should cut the cards, or declare a go on behalf of the player

I am assuming the error is related to the fact that a replay DB cannot be modified?

I don't know how to stop that code from firing though because during a replay

Code: Select all

this.isSpectator
is false, so I can't use that

Has anyone run into this error before ?

Re: Replay of Game not working because of DB modification?

Posted: 04 September 2020, 12:31
by Tisaac
Maybe you should use this to detect replay :

Code: Select all

typeof g_replayFrom != 'undefined'
    Returns true if the game is in instant replay mode (replay during the game)

g_archive_mode
    Returns true if the game is in archive mode (advanced replay after the game has ended)
(Source : http://en.doc.boardgamearena.com/Game_i ... neral_tips)

Re: Replay of Game not working because of DB modification?

Posted: 04 September 2020, 15:02
by MikeIsHere
Thank you
g_archive_mode
worked