getAllDatas VS stCustomGameState

Game development with Board Game Arena Studio
Post Reply
User avatar
tarini
Posts: 45
Joined: 11 July 2013, 22:36
Location: italy
Contact:

getAllDatas VS stCustomGameState

Post by tarini »

Hi, I've got an issue about getAllDatas method and other state methods call order.

Assume I have a unique game state called stNextPhase that directly follow gameSetup.

In this method I give each player 5 cards updating "location" column inside database and for each of these cards I trigger a notification to the owner player using:

Code: Select all

self::DbQuery("UPDATE florenza_card SET location = 'hand', player_id = " . $playerId . " WHERE card_id IN (" . $ids . ")");
foreach($ids as $cardId) {
        self::notifyPlayer($playerId, "cardDrown", clienttranslate('You draw ${cardname}'), array(
	       "card" => $card,
	       "cardname" => $card['titleTr']
        ));
}
Now inside my getAllDatas I need to retrieve player's cards (and pass them to the user) to ensure that, if he refreshes page, he will get cards he actually has in his hand keeping game consistent. So I wrote this code:

Code: Select all

$result['hand'] = $this->myCustomSelectMethod("WHERE player_id = $current_player_id AND location = 'hand'");
Now I expect that as soon as the game starts, every player has 5 cards in his hand and 5 notification "You draw ${cardname}" in his console, but not!

The cards are regularly inside players' hands but there are not any notifications. User is notified about his cards only thanks to getAllData but no notifications comes to him.
I except that when getAllDatas method is calling, every player has no cards in his hand because getAllDatas (on game setup) is called BEFORE stNextPhase.
Obviously if i comment the UPDATE sql command inside my stNextPhase, players have 0 cards in their hands.

It seems that the calling order is:
setupNewGame ----> stNextPhase ----------> getAllDatas
User avatar
pikiou
Posts: 389
Joined: 03 October 2011, 05:36

Re: getAllDatas VS stCustomGameState

Post by pikiou »

I encounter this issue once every 3 game : the notifications you send between game start and the end of the state entering function of the first active state are ignored, they go to oblivion.

I'm fairly sure I reported this bug to admins a year ago, but it must be way more difficult to fix than we expect.

I'll write something about it in the wiki, but all new devs will fall for it so dear admins if you can't fix it, could you raise an exception when such a notification is fitted and won't reach its destination ? Or write something about it in the template you clone when a new project is created ?
User avatar
tarini
Posts: 45
Joined: 11 July 2013, 22:36
Location: italy
Contact:

Re: getAllDatas VS stCustomGameState

Post by tarini »

Hi thanks for reply.

Could you please tell me where can I find what have you wrote on the wiki about this issue?

And, what about my intuition about method order when game is setting up? Except for bug you report, it's correct this logical sequence?
setupNewGame ----> stNextPhase ----------> getAllDatas

It seems wrong to me...or maybe it's just a synchrony problem?
User avatar
pikiou
Posts: 389
Joined: 03 October 2011, 05:36

Re: getAllDatas VS stCustomGameState

Post by pikiou »

You are probably right about the function call order. Or the notification system is initialized after getAllDatas.
Either way, you should avoid using notifications before a player has had the chance to interact.

I'll edit the wiki when I'm back home.
Post Reply

Return to “Developers”