getAllDatas VS stCustomGameState
Posted: 19 August 2014, 20:58
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:
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:
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
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']
));
}Code: Select all
$result['hand'] = $this->myCustomSelectMethod("WHERE player_id = $current_player_id AND location = 'hand'");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