Page 1 of 1
Implementing Change mind while others are deciding
Posted: 14 September 2020, 15:53
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.
Re: Implementing Change mind while others are deciding
Posted: 14 September 2020, 17:00
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.
Re: Implementing Change mind while others are deciding
Posted: 14 September 2020, 18:53
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

, 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" );
}
Re: Implementing Change mind while others are deciding
Posted: 14 September 2020, 19:12
by Volker78
I also used it in "turn the tide". The trick is the "checkPossibleAction" instead of "checkAction"
Re: Implementing Change mind while others are deciding
Posted: 15 September 2020, 00:09
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);
}
Re: Implementing Change mind while others are deciding
Posted: 25 September 2020, 16:34
by CuriousTerran
Thank you all, this was very helpful. I was able implement this for Via Magica