Page 1 of 1

PB solved involves a question:

Posted: 11 May 2013, 20:54
by Rudolf
Hello,
well I just solved a pb that was concerning several things: slide, step and getactiveplayerid...
the way I was coding was not in the right spirit, because I needed not existing thing...
In a sequence, I had a first step selecting a choice of 4 ways game states, with different behaviour. these 4 ways began with an init game step and goes to a step of active player,
First idea was to include code on EnteringState, but after coding, I realise that in js, I cannot get ActivePlayer (because functions return null) in a game state....
So I change solution and goes to php to include a notify that transfers playerid from php (because php can get this activeplayer even in game state), and it solved my pb.

But... at final, I've added more functions (notify, subscribe, ...) only to replace a simple call... why could it be not possible to get activeplayerid when we're in a game state (in javascript file)?

Re: PB solved involves a question:

Posted: 11 May 2013, 21:32
by pikiou
Because activeplayerid is subject to change in a game state and if you could change it, it'd lead to difficult bugs to fix.

Couldn't you use this.getActivePlayerId() at the end of the previous active state or at the beginning of the next active state?

Re: PB solved involves a question:

Posted: 12 May 2013, 00:21
by Rudolf
Hum... pb with case of refresh F5 in this case ;), but I use notify... and it's running... it was just in case. ;)

Re: PB solved involves a question:

Posted: 14 May 2013, 20:07
by sourisdudesert
Hello,

it seems that you try to twist the framework by doing this...

You are not supposed to get active player id on a game state, it has no meaning. If you do it, there's a risk that some future change in the framework will break your game.

You should do as suggested by Pikiou. There is no refresh problem because your game should never stays in a "game" type game state.

Cheers,

Re: PB solved involves a question:

Posted: 19 May 2013, 18:12
by Rudolf
But 'before' and 'after' it's a player state... by the way... I used notify and it runs with that.