Implementing Change mind while others are deciding

Game development with Board Game Arena Studio
Post Reply
User avatar
CuriousTerran
Posts: 21
Joined: 12 July 2020, 21:03

Implementing Change mind while others are deciding

Post by CuriousTerran »

I am looking for a game in studio that I can look at read-only that has implemented a multipleactiveplayer state where people are able to change their minds on the current play while others are still deciding. I only know of Sushi-Go that does this, but it isn't in studio. I wanted to look at implementing this for a game in Alpha and didn't want to reinvent the wheel. Let me know games or documentation that describes this. Presumeably it involves tracking in custom DB or global variables whos submitted move rather than relying on builtin $this->gamestate->setPlayerNonMultiactive( $player_id, $next_state ) to keep track of this. Thanks.
User avatar
hersh
Posts: 76
Joined: 12 December 2013, 23:49

Re: Implementing Change mind while others are deciding

Post by hersh »

I tried a few games of "A Fistful of Gold" and I think it has this concept. I think you still set player as non-active but let them send actions anyway.
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Implementing Change mind while others are deciding

Post by RicardoRix »

I did it in Saint Poker, but I copied it from somewhere else (can't remember where) and so I can't verify the logic either :oops:, but it worked.

Code: Select all

	// via JS: ajax callback, player has just selected a card from their hand.
	function selectRiverCardFromHand( $card_ids )
    {		
		$this->gamestate->checkPossibleAction( 'selectRiverCardFromHand' );
		
		$player_id = self::getCurrentPlayerId();  
		
   	    $isPlayerActive = self::getUniqueValueFromDB("SELECT player_is_multiactive FROM player WHERE player_id = $player_id");
    
		$this->cards->moveAllCardsInLocation('riverToBe', 'hand', $player_id, $player_id); //undo any previous selection changes.
		$this->cards->moveCards($card_ids, 'riverToBe', $player_id);	
		
		$riverCardsToBe = $this->cards->getCardsInLocation('riverToBe', $player_id);		
		
        if (!$isPlayerActive)
		{
			// not active == this player already has chosen a card.	
			self::notifyPlayer($player_id, 'riverCardToBe', clienttranslate( 'You have changed your selection to ${cardtext}'), array(
				'cardtext' => '<br />' . $this->formatCardsText($riverCardsToBe),
				'cards' => $riverCardsToBe
			));
			
			$this->gamestate->updateMultiactiveOrNextState( 'completeSelectRiverCardFromHand' );    
			return;
		}      
		
    	self::checkAction( "selectRiverCardFromHand" );
		
		self::notifyPlayer( $player_id, 'riverCardToBe', clienttranslate( 'You selected a card from your hand.' ), array(
            'cards' => $riverCardsToBe            
        ));		

		$this->gamestate->setPlayerNonMultiactive( $player_id, "completeSelectRiverCardFromHand" );			
	}	
User avatar
Volker78
Posts: 66
Joined: 29 April 2020, 21:37

Re: Implementing Change mind while others are deciding

Post by Volker78 »

I also used it in "turn the tide". The trick is the "checkPossibleAction" instead of "checkAction"
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Implementing Change mind while others are deciding

Post by Victoria_La »

Basically you have to turn off check for action on js and on server it looks like

Code: Select all

    function actionCancel() {
        $this->gamestate->checkPossibleAction('actionCancel');
        $this->gamestate->setPlayersMultiactive(array ($this->getCurrentPlayerId() ), 'error', false);
    }
User avatar
CuriousTerran
Posts: 21
Joined: 12 July 2020, 21:03

Re: Implementing Change mind while others are deciding

Post by CuriousTerran »

Thank you all, this was very helpful. I was able implement this for Via Magica
Post Reply

Return to “Developers”