Making the result of a trick obvious (with a delay?)

Game development with Board Game Arena Studio
Post Reply
User avatar
Bids
Posts: 72
Joined: 02 April 2019, 18:10

Making the result of a trick obvious (with a delay?)

Post by Bids »

Hi all!
I would like to get some advice on this: In Bids there is a special card that means that players are not knowing for how many points they are bidding in that turn. This is called the "surprise" card. In the real game this happens when the surprise card is laying on top of the black card pile. When every player has placed his bid for that turn, the next black card is turned around, and that's the card that the player will win.
I was thinking to implement this as follows:

Code: Select all

function stSurpriseCard() {
    	$nextBlack = $this->cards->getCardOnTop('blackontop');
        self::notifyAllPlayers( 'newTrick', clienttranslate('new trick'),array( 'nextBlack' => $nextBlack ));
        sleep(3);
	$this->gamestate->nextState("");	
    }
    
So when the trick is finished, normally the nextState will be "newTrick", but if the special card was laying on top, the next state will be "surpriseCard" which activates this function. The black card on top will be replaced with a new black card. After waiting 3 seconds, the next state will be activated, which will be "newTrick".
So a double question here: how do I use the "sleep" function correctly, because the code like this is not working. Or is there another way of implementing this logic, such that it is obvious for the players what the winner of that trick will win?
Many thanks in advance!
User avatar
hersh
Posts: 76
Joined: 12 December 2013, 23:49

Re: Making the result of a trick obvious (with a delay?)

Post by hersh »

you don't need the server to sleep. you can still send the move to the client and delay the reveal or transition back to 'newTrick' on the client.

depending on situation maybe use of setTimeout() or synchronous notifications
User avatar
Bids
Posts: 72
Joined: 02 April 2019, 18:10

Re: Making the result of a trick obvious (with a delay?)

Post by Bids »

Thanks a lot! This was exactly what I was looking for.
Post Reply

Return to “Developers”