Change card selection while waiting for other players

Game development with Board Game Arena Studio
Post Reply
User avatar
Yu-wolf-or-Oru
Posts: 14
Joined: 15 July 2020, 12:27

Change card selection while waiting for other players

Post by Yu-wolf-or-Oru »

Hi everyone!
Thank you for helping me every time.

Question↓
What kind of code could be used to achieve a specification that allows multiple selection changes (e.g. 6nimmt) in a multi-active type state until other players have decided on their choice?

Greetings
Oru
User avatar
robinzig
Posts: 461
Joined: 11 February 2021, 18:23

Re: Change card selection while waiting for other players

Post by robinzig »

I've not implemented this myself, but I think this section of the docs might be what you're looking for? (It's confusing that it talks about "un-passing" when what you want to undo usually isn't a "pass" but an actual choice/action - but I believe that's what this section is talking about.)
User avatar
Yu-wolf-or-Oru
Posts: 14
Joined: 15 July 2020, 12:27

Re: Change card selection while waiting for other players

Post by Yu-wolf-or-Oru »

Dear robinzig

Sorry I did not notice your reply!
Thank you for the very useful information.
I will read the content immediately and try my best.
Thanks.

Oru
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: Change card selection while waiting for other players

Post by tchobello »

hello

I think Tisaac is using this in Welcome To...
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Change card selection while waiting for other players

Post by RicardoRix »

I stole this code, I can't attest to it's logic, it seems to work:

Code: Select all

	
function draftSelection( $id )
    {		
		$this->gamestate->checkPossibleAction( 'draftCard' );
		
		$player_id = self::getCurrentPlayerId();  
		
    	    $isPlayerActive = self::getUniqueValueFromDB("SELECT player_is_multiactive FROM player WHERE player_id = $player_id");
    
		//undo any previous selection changes, 
		// update for current selection.
		// ...
				
        if (!$isPlayerActive)
		{
			// not active == this player already has chosen a card.	
			self::notifyPlayer($player_id, 'draftPick', clienttranslate( 'You have changed your selection to ${name}'), [
				'name' => $card->name,
				'card' => $card,
			]);
			
			$this->gamestate->updateMultiactiveOrNextState( 'resolveDraftCard' );    
			return;
		}      
		
    	self::checkAction( "draftCard" );
		
		self::notifyPlayer( $player_id, 'draftPick', clienttranslate( 'You selected $name}' ), [
        		'name' => $card->name,
				'card' => $card,
		]);		

		$this->gamestate->setPlayerNonMultiactive( $player_id, "resolveDraftCard" );			
	}	
User avatar
Yu-wolf-or-Oru
Posts: 14
Joined: 15 July 2020, 12:27

Re: Change card selection while waiting for other players

Post by Yu-wolf-or-Oru »

Dear tchobello and RicardoRix

Thank you for your comment.
RicardoRix,The code you gave me taught me something new.
-> I did not know that the active state is managed in the player table.
I will try out a few different things.
Please continue to hope that my game will work properly in the future.
Oru
Post Reply

Return to “Developers”