How to detect game end

Game development with Board Game Arena Studio
User avatar
disu
Posts: 62
Joined: 10 February 2016, 08:47

How to detect game end

Post 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 :(
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: How to detect game end

Post 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
User avatar
disu
Posts: 62
Joined: 10 February 2016, 08:47

Re: How to detect game end

Post 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?
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: How to detect game end

Post by Tisaac »

Put it in getAllDatas
User avatar
disu
Posts: 62
Joined: 10 February 2016, 08:47

Re: How to detect game end

Post 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?
User avatar
robinzig
Posts: 461
Joined: 11 February 2021, 18:23

Re: How to detect game end

Post 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.
User avatar
disu
Posts: 62
Joined: 10 February 2016, 08:47

Re: How to detect game end

Post 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!
User avatar
AxeCrazy
Posts: 90
Joined: 15 March 2014, 01:07

Re: How to detect game end

Post 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?
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: How to detect game end

Post by thoun »

I use this in getAllDatas :
$isEndScore = intval($this->gamestate->state_id()) >= ST_END_SCORE;
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: How to detect game end

Post 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 ? :)
Post Reply

Return to “Developers”