Page 1 of 1
Cannot get back into my game (Propagating error from GS 1)
Posted: 27 January 2021, 02:53
by SardaukarWI
I was working on the NotifyAllPlayers() call from game.php and in testing I had an error that stated that ${player_name} was not defined. I saw that I didn't include 'player_name' in the arguments of the call, so I copied the line from the example right below within the comments of the file.
'player_name' => self::getActivePlayerName(),
After sync'ing, I refreshed my page and it was still complaining about the player_name without me taking any actions because there was an entry in the notification log still from the previous attempt. So I just stopped the game and created a new one. And that's when the trouble began. The game failed to create and I received an error stating the following:
ly_metasite.js:2 Unexpected error: Propagating error from GS 1 (method: createGame): Fatal error during herekittykitty setup: Not logged
Digging through this forum, I found multiple references stating that you could not use the call to "getActivePlayerName()". Also stated it on the Troubleshooting wiki page. So I backed that change out and put it back the way it was. Unfortunately, I'm still getting this error when I try to create a game. I am now stuck and don't know how to proceed. There are not any references to getActivePlayerName() in my code. But there is obviously something still lingering. I tried clearing cache, but no change. How do I fix this?
Thanks,
Dan
Re: Cannot get back into my game (Propagating error from GS 1)
Posted: 27 January 2021, 04:31
by Victoria_La
There is error during setup game method, you have to checkout you previous change and see what you have changed.
You can also look at exceptions log to see if anything is logged. Most of the reasons are on that troubleshooting page though.
Re: Cannot get back into my game (Propagating error from GS 1)
Posted: 27 January 2021, 21:19
by SardaukarWI
I wasn't able to view the log by going to the below URL. It gave me an unable to find database error "Unable to find table database (1): ebd_herekittykitty_238962"
https://studio.boardgamearena.com/1/her ... ble=238962
So I saved a backup of my local files and reverted back to my check-in from the 24th. But I'm still receiving the same error trying to create a game. Now, it has been quite a while since I actually created a new game since I haven't made any DB schema changes recently. So reverted again to the 23rd check-in. Now it works and I can get to the log with the above URL or through the game interface.
So obviously I made an error many days ago that prevents me from creating games, but an already created game continues on just fine. Though I never knew it because I never created a new game. Now for the process of isolating what caused the problem in the first place. And lesson learned, always test with a newly created game as well.
Thanks.
Re: Cannot get back into my game (Propagating error from GS 1)
Posted: 28 January 2021, 02:25
by SardaukarWI
Ok, I found the offending line of code. In a game state argument function ( e.g. argPlayerTurn() ), I call the function self::getCurrentPlayerId(). If I comment this call out, it loads fine. If I put it back in, I cannot create a game.
Now once the game is created, this function is working just fine. In this game state argument function, I am returning a list of valid objects that can be selected when in the corresponding state. Now, only the active player can select these, so I was comparing the active player to current player and if not equal simply returning an empty list.
But thinking about it, at the time the game is created there is no current player yet and the game immediately advances to the first player state and calls this function. But if there is no client yet, and therefore no current player, why is this function even being called? It is to generate data to send to the client when entering a state. But there is no client yet at this time.
Looking on the Wiki for this function it states:
Very important: in your setupNewGame and zombieTurn function, you must never use getCurrentPlayerId() or getCurrentPlayerName(), otherwise it will fail with a "Not logged" error message (these actions are triggered from the main site and propagated to the gameserver from a server, not from a browser. As a consequence, there is no current player associated to these actions).
Though this is not in a setup game function, hence my confusion. But I'll have to figure out how to change how I'm doing this.
Re: Cannot get back into my game (Propagating error from GS 1)
Posted: 28 January 2021, 14:09
by Benoit314
I suggest you to read the docs on args functions:
http://en.doc.boardgamearena.com/Your_g ... c.php#args
As you've discovered, you cannot use current player, there is none as it is sent to everyone.
For your need, check the part on private infos, that's what you should do in your case.
Re: Cannot get back into my game (Propagating error from GS 1)
Posted: 28 January 2021, 15:14
by SardaukarWI
Thanks for the link. I was trying to make it such that only valid items were selectable by the active player and since I already had to write logic on the backend to determine what was valid or what was not, just send that down to the client. But now as I play various games on BGA I'm starting to play around with the interfaces to see how they behave, particularly when it is not my turn. I find many simply let the user select anything, then either it doesn't do anything because it's not your turn, says it's not your turn (checkAction), or displays a "not a valid move" error from the backend. That will be a simpler approach and for the most part, players won't be selecting invalid items. I need to stop trying to lock everything down and keep the frontend simple.
Re: Cannot get back into my game (Propagating error from GS 1)
Posted: 28 January 2021, 18:54
by Benoit314
There is 2 approaches in games: show only valid options to players or let the player click anywhere then display an error message.
If you check games like Welcome to, it only shows valid options. I think it makes the flow of the game a bit faster, players don't have to consider and analyse invalid choices... Then make a mental note...
It may depends on the game.
Re: Cannot get back into my game (Propagating error from GS 1)
Posted: 28 January 2021, 20:19
by Tisaac
SardaukarWI wrote: ↑28 January 2021, 15:14
Thanks for the link. I was trying to make it such that only valid items were selectable by the active player and since I already had to write logic on the backend to determine what was valid or what was not, just send that down to the client. But now as I play various games on BGA I'm starting to play around with the interfaces to see how they behave, particularly when it is not my turn. I find many simply let the user select anything, then either it doesn't do anything because it's not your turn, says it's not your turn (checkAction), or displays a "not a valid move" error from the backend. That will be a simpler approach and for the most part, players won't be selecting invalid items. I need to stop trying to lock everything down and keep the frontend simple.
Active and current player are not the same things. You can use active Player anywhere without any trouble