Page 1 of 1

Starting Games Error

Posted: 22 January 2016, 19:39
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.

Re: Starting Games Error

Posted: 22 January 2016, 20:34
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.

Re: Starting Games Error

Posted: 23 January 2016, 22:41
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...

Re: Starting Games Error

Posted: 18 July 2019, 11:26
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

Re: Starting Games Error

Posted: 19 July 2019, 09:13
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

Re: Starting Games Error

Posted: 19 July 2019, 10:07
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!

Re: Starting Games Error

Posted: 20 July 2019, 11:20
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

Re: Starting Games Error

Posted: 20 July 2019, 11:44
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!