Page 1 of 1

Change card selection while waiting for other players

Posted: 25 June 2023, 03:51
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

Re: Change card selection while waiting for other players

Posted: 25 June 2023, 10:27
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.)

Re: Change card selection while waiting for other players

Posted: 03 July 2023, 08:43
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

Re: Change card selection while waiting for other players

Posted: 03 July 2023, 08:49
by tchobello
hello

I think Tisaac is using this in Welcome To...

Re: Change card selection while waiting for other players

Posted: 03 July 2023, 09:53
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" );			
	}	

Re: Change card selection while waiting for other players

Posted: 04 July 2023, 12:42
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