Starting Games Error

Game development with Board Game Arena Studio
Post Reply
User avatar
apollo1001
Posts: 191
Joined: 21 July 2015, 10:41

Starting Games Error

Post by apollo1001 »

Hi All

Anyone else getting a error when attempting to start a game?:
Unexpected error: Propagating error from GS 1 (method: createGame): Fatal error during <gamenamehere> setup: Not logged
Currently happening with both my projects, but it might be possible the framework is simply being upgraded as nothing has changed on one of the projects since Wednesday when it was working fine.

A.
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: Starting Games Error

Post by sourisdudesert »

Hi

Usually it happens when you try to get current user id during setup phase.

Current user id is the player who initiate a request. During setup phase there is of course no current player id, and this thriw an exception.

Hope this helps.
User avatar
apollo1001
Posts: 191
Joined: 21 July 2015, 10:41

Re: Starting Games Error

Post by apollo1001 »

Thanks - that was indeed the problem if anyone has a similar problem. using self::getCurrentPlayerId() even when collecting the args for the first state will throw the error...
User avatar
JumpMaybe
Posts: 41
Joined: 20 June 2019, 14:25

Re: Starting Games Error

Post by JumpMaybe »

apollo1001 wrote: 23 January 2016, 22:41 using self::getCurrentPlayerId() even when collecting the args for the first state will throw the error...
Exactly... isn't this a bug in the framework?

After GameSetup I have a default transition ("" => 2) to state 2, which is a multipleactiveplayer state with an "args" function.
The game will fail to start (same error as the OP mentioned) when I call self::getCurrentPlayerId() in this args function, even though I have to know the currentPlayerId to get the correct data to each player. I don't know why this args function is called in the first place when creating the game, aren't args functions only useful to feed the front end data?

Anyway, if I comment out the self::getCurrentPlayerId() line during initial game setup, and then enable it again when opening the game as a player, the game will no longer crash, and self::getCurrentPlayerId() works as desired.

I have now come up with this ugly workaround to get it working without manual action:

Code: Select all

if(is_numeric(array_shift($this->gamestate->state()['reflexion']['total']))) {
    // Normal gameplay, use self::getCurrentPlayerId() to return real data.
}
else {
    // Initial setup, return dummy data without using self::getCurrentPlayerId().
}
This works because at game setup time, these reflexion totals aren't filled yet, which is the only difference I could find between gamestate at gamesetup or during play.

Please let me know the real way to do this ;)

- Koen
vincentt
Posts: 247
Joined: 01 September 2017, 17:25

Re: Starting Games Error

Post by vincentt »

Hi

I guess you could add a transitionnal state "just" to make it to another state. I do have game states before having the multiactive state and it works

Vincent
User avatar
Een
Posts: 3854
Joined: 16 June 2010, 19:52

Re: Starting Games Error

Post by Een »

Actually the args function is not there to convey private information: everytime there is a gamestate change the args function data is broadcast to all players (bundled with the gamestate change), independently of the current player who triggered the gamestate change.

So it's not a good idea to hack it to do that :)

All private information should be sent through a private notification (notifyPlayer) and included in getAllDatas (in case of a refresh).

For example in werewolves of miller's hollow where in the first game phase players have to check their secret role:
- first we transition to a "game" state gameMultiplayerPreparationPhase where in the stMultiplayerPreparationPhase we use notifyPlayer to inform each player of his role privately
- then we transition to the "multiplayer" state multiplayerPreparationPhase
- to handle the player refreshing the page, we also return the private role in getAllDatas based on the current player id.

Hope it helps for your specific use case!
User avatar
JumpMaybe
Posts: 41
Joined: 20 June 2019, 14:25

Re: Starting Games Error

Post by JumpMaybe »

Thank you Een for taking the time to correct and help me.
I did read the documentation but don't "live and breath" it yet.. hence mistakes like this one.
I stand corrected and am excited to continue working on my first game implementation.

Koen
User avatar
Een
Posts: 3854
Joined: 16 June 2010, 19:52

Re: Starting Games Error

Post by Een »

JumpMaybe wrote: 20 July 2019, 11:20 Thank you Een for taking the time to correct and help me.
I did read the documentation but don't "live and breath" it yet.. hence mistakes like this one.
I stand corrected and am excited to continue working on my first game implementation.

Koen
Well, this is a fine point, actually I wasn't so sure myself at first and had to check to remember how it should be done :)
Have fun developing!
Post Reply

Return to “Developers”