Error ending multiplayer state

Game development with Board Game Arena Studio
Post Reply
User avatar
cmgames
Posts: 16
Joined: 05 October 2016, 22:14

Error ending multiplayer state

Post by cmgames »

When clicking the 'Done' button when in a multiplayer state, I perform a function (finishedSelectingCards) and transition to the next state (waitUntilAllDone). In that state action (stWaitUntilAllDone), I set the "done" player to non-multiactive and specify the transition.

My problem is that *each* player gets an error "Unexpected final game state (7)" when he clicks his 'Done' button. And the transition out of the waiting state never happens, even once all players are done.

~cmgames

function stWaitUntilAllDone(){
$player_id = self::getCurrentPlayerId();
$this->gamestate->setPlayerNonMultiactive($player_id, "allDone");
}

7 => array(
"name" => "waitUntilAllDone",
"description" => 'Wait until all players have finished choosing.',
"type" => "game",
"action" => "stWaitUntilAllDone",
"transitions" => array("allDone" => 8)
),
User avatar
tchobello
Posts: 693
Joined: 18 March 2012, 13:19

Re: Error ending multiplayer state

Post by tchobello »

hello...

you don't need the waitUntilAllDone transition.

when a player clicks on 'Done', you get back to PHP via AJAX Call.
You just need to write
$this->gamestate->setPlayerNonMultiactive($player_id, "allDone");
at the end and the allDone transition will be performed once all players have clicked on 'Done'

here is an example :
STATES

Code: Select all

20 => array(
        "name" => "grandTichuBets",
        "description" => clienttranslate('All players must choose if they want to bet a Grand Tichu'),
        "descriptionmyturn" => clienttranslate('${you} must choose if you want to bet a Grand Tichu'),
        "type" => "multipleactiveplayer",
        "action" => "stGrandTichuBets",
        "possibleactions" => array( "grandTichuBet" ),
        "transitions" => array( "dealLastCards" => 30 )
    ),
30 => array(
        "name" => "dealLastCards",
        "description" => '',
        "type" => "game",
        "action" => "stDealLastCards",
        "transitions" => array( "giveCards" => 40 )
    ),        
    
PHP

Code: Select all

   function grandTichuBet( $bet )
    {
        self::checkAction( 'grandTichuBet' );

        $player_idm = self::getCurrentPlayerId();

        $handcount = $this->cards->countCardInLocation( 'hand', $player_idm );
        if( $handcount <> 8 )
            throw new feException( "Can't make grand tichu bet: you don\'t have 8 cards" );

        $current_bet = self::getUniqueValueFromDB( "SELECT player_call_grand_tichu FROM player WHERE player_id='$player_idm' " );
        if( $current_bet >= 0 )
            throw new feException( "Can't make bet: you already bet" );

        if( $bet == 0 )
            $notify = clienttranslate( '${player_name} makes no Grand Tichu bet' );
        elseif( $bet == 200 )
        {
            $notify = clienttranslate( '${player_name} makes a Grand Tichu bet' );
            self::DbQuery( "UPDATE player SET player_call_tichu=0 WHERE player_id='$player_idm' ");

            self::incStat( 1, 'grandtichu_number', $player_idm );
        }
        else
            throw new feException( "Wrong bet value" );

        self::DbQuery( "UPDATE player SET player_call_grand_tichu='$bet' WHERE player_id='$player_idm' ");

        self::notifyAllPlayers( "grandTichuBet", $notify, array(
                    "player_id" => $player_idm,
                    "player_name" => self::getCurrentPlayerName(),
                    "bet" => $bet
        ) );

        self::incGameStateValue( 'nbGrandTichuBets', 1 );

        $this->gamestate->setPlayerNonMultiactive($player_idm, "dealLastCards");
    }
kerinbot
Posts: 5
Joined: 15 July 2020, 03:57

Re: Error ending multiplayer state

Post by kerinbot »

I hope it's okay to post this question here, while you're talking about code, but I just wanted to ask: does this mean that someone is actively working on adding the game Tichu to boardgamearena? I had seen on another forum, that the publisher has given permission for it to be added here.

But of course, first it needs to be programmed... If that's in progress already, I'm delighted and thank you all!

Has anyone set up something like a tip jar for programmers that work on particular games that people are enthusiastic about, in order to thank and reward the people working on particular games?
User avatar
Draasill
Posts: 197
Joined: 26 April 2020, 00:00

Re: Error ending multiplayer state

Post by Draasill »

The game is currently in alpha, developed by vinayakr (https://boardgamearena.com/player?id=85873058).

You can ask him access to the alpha, I guess =)
Post Reply

Return to “Developers”