Page 1 of 2

How to detect game end

Posted: 05 November 2021, 18:44
by disu
Hi,
when my game finished I push a notification to players and make some changes to their game page.
But, if a player refresh the page, I don't know how to detect the game end status in getAllDatas to make the same graphic changes.

Sorry I know it is written somewhere in this bunch of docs pages but I didn't find it :(

Re: How to detect game end

Posted: 05 November 2021, 20:08
by Tisaac
disu wrote: 05 November 2021, 18:44 Hi,
when my game finished I push a notification to players and make some changes to their game page.
But, if a player refresh the page, I don't know how to detect the game end status in getAllDatas to make the same graphic changes.

Sorry I know it is written somewhere in this bunch of docs pages but I didn't find it :(
onEnteringState will still be runned with the state "endgame" so you can put your code there

Re: How to detect game end

Posted: 26 November 2021, 18:30
by disu
I am able to retrieve from DB infos to show if player refresh page after game end. And it works well.
But I did it overriding argGameEnd function (for state 99) and padding as argument the data read from DB. Something like this:

Code: Select all

function argGameEnd()
{
     $players = $this->gameManager->getPlayers(true);
     return array(
         'players' => $players
     );
}
But in the documentation it is discouraged the overriding of system argGameEnd function (and also in the Victoria_La tests, into developer dashboard). So how can I do in another way?

Re: How to detect game end

Posted: 26 November 2021, 18:30
by Tisaac
Put it in getAllDatas

Re: How to detect game end

Posted: 26 November 2021, 18:34
by disu
Tisaac wrote: 26 November 2021, 18:30 Put it in getAllDatas
I've already supposed to put in getAllDatas in my first post. But if I put here how can I check if the game is finished?

Re: How to detect game end

Posted: 26 November 2021, 19:14
by robinzig
disu wrote: 26 November 2021, 18:34
Tisaac wrote: 26 November 2021, 18:30 Put it in getAllDatas
I've already supposed to put in getAllDatas in my first post. But if I put here how can I check if the game is finished?
You can check the current game state. It will be 99 if the game is over.

Re: How to detect game end

Posted: 28 November 2021, 13:42
by disu
robinzig wrote: 26 November 2021, 19:14
disu wrote: 26 November 2021, 18:34
Tisaac wrote: 26 November 2021, 18:30 Put it in getAllDatas
I've already supposed to put in getAllDatas in my first post. But if I put here how can I check if the game is finished?
You can check the current game state. It will be 99 if the game is over.
It was so obvious :)
I didn't use the function for check current state yet. Thanks!

Re: How to detect game end

Posted: 16 February 2024, 10:53
by AxeCrazy
i have a simular "problem".
I modify the state of the board (to get visual representation of the game) and after that check endgame.
When i look at the board in the gaestate object it does not hold the latest data, but when i refresh the page the last state is indeed the gameEndState.
How can i make sure the state of the "board" that i added to the getAllDatas function is updated after each state change?

Re: How to detect game end

Posted: 16 February 2024, 13:31
by thoun
I use this in getAllDatas :
$isEndScore = intval($this->gamestate->state_id()) >= ST_END_SCORE;

Re: How to detect game end

Posted: 16 February 2024, 20:48
by Tisaac
thoun wrote: 16 February 2024, 13:31 I use this in getAllDatas :
$isEndScore = intval($this->gamestate->state_id()) >= ST_END_SCORE;
Wouldnt that be dangereous if you use state with ids > 100 ? :)