refer to current state in php

Game development with Board Game Arena Studio
Post Reply
User avatar
ddyer
Posts: 67
Joined: 01 April 2011, 19:55

refer to current state in php

Post by ddyer »

what's the recommended way to branch based on the current state in GetAllDatas ?

If I want to set a checkpoint, similar in effect to what the devevelopment environment "save" and "load" do, is
there a built-in mechanism for that or am I on my own.

Is there a way to use "load" to load a game which has been finished. In other words, suppose I saved
a game just before finish, and finish as part of the testing, and want to get back to the just before
finished state.
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: refer to current state in php

Post by sourisdudesert »

Hello,

Most of the time you don't need to have a branch condition in getAllDatas. If your data is specific to one particular game state, please consider using game state argument features. Otherwise, if you really need to access current game state, you can do this:

$state = $this->gamestate->state();
if( $state['name'] == 'xxxxxx' )
....

About the "checkpoint" feature: there is no built in mechanism for this. Most of the time you don't need it, because of the transaction database system (your database don't change until the move is valid) and the fact that we don't recommend to allow players to cancel their moves.

Finally: actually there's no feature to restore a situation when the game has ended. The best thing to do is to place a "die" just before the game end to test the end of the game.

Cheers,
User avatar
ddyer
Posts: 67
Joined: 01 April 2011, 19:55

Re: refer to current state in php

Post by ddyer »

sourisdudesert wrote: About the "checkpoint" feature: there is no built in mechanism for this. Most of the time you don't need it, because of the transaction database system (your database don't change until the move is valid) and the fact that we don't recommend to allow players to cancel their moves.
...
Go has a fairly unique endgame, where players remove "dead" stones and see what the computer calculates as
the final score. Sometimes they disagree about what is dead, and sometimes they discover that the game wasn't
really over after all. So coping with this "maybe endgame" I have to be able to unwind the endgame steps made.
Post Reply

Return to “Developers”