Page 1 of 1

How multiactiveplayer states work

Posted: 20 September 2014, 10:56
by adela82
I'm working on a cooperative game, where all players must decide what to do everytime. But I can't find clear documentation about multictiveplayer state games.

In my game, players can propose an action or vote others' actions. Once the team agree with one action, those can be: move a resource, solve a challenge or use a power (or pass)

I don't know if I have to place as possibleActions the current colective actions:

Code: Select all

    30 => array(
    		"name" => "teamTurn",
    		"description" => clienttranslate('${you} propose an Action or answer others\' proposals'),
    		"descriptionmyturn" => clienttranslate('${you} propose an Action or answer others\' proposals'),
    		"type" => "multipleactiveplayer",
    		"args" => "argTeamTurn",
    		"possibleactions" => array("moveAResource", "solveAChallenge", "useAPower", "pass"),
    		"transitions" => array("moveAResource" => 40, "solveAChallenge" => 50, "useAPower" => 60, "pass" => 90)
    ),  
Or to place the current single player actions, and make a loop to the same state:

Code: Select all

 
     30 => array(
    		"name" => "teamTurn",
    		"description" => clienttranslate('${you} propose an Action or answer others\' proposals'),
    		"descriptionmyturn" => clienttranslate('${you} propose an Action or answer others\' proposals'),
    		"type" => "multipleactiveplayer",
    		"args" => "argTeamTurn",    		
    		"possibleactions" => array("proposeAnAction", "cancelProposal", "answerAProposal", "pass"),
    		"transitions" => array("proposeAnAction" => 30, "cancelProposal" => 30, "answerAProposal" => 30, "pass" => 30) 
    ),
If it's the first case, how I get the actions made by the players.

If it's the second case, I don't know how to tell the program the next state. Maybe this is one solution?

Code: Select all

     30 => array(
    		"name" => "teamTurn",
    		"description" => clienttranslate('${you} propose an Action or answer others\' proposals'),
    		"descriptionmyturn" => clienttranslate('${you} propose an Action or answer others\' proposals'),
    		"type" => "multipleactiveplayer",
    		"args" => "argTeamTurn",    		
    		"possibleactions" => array("proposeAnAction", "cancelProposal", "answerAProposal", "pass"),
    		"transitions" => array("proposeAnAction" => 30, "cancelProposal" => 30, "answerAProposal" => 30, "pass" => 30, "teamMovesAResource" => 40, "teamSolvesAChallenge" => 50, "teamUsesAPower" => 60, "teamPass" => 90) 
    ),
If it works the second way, of course.

I'm lost!

Re: How multiactiveplayer states work

Posted: 24 September 2014, 13:07
by sourisdudesert
Hi,

thanks for contributing on BGA Studio.

Be careful using the word "action" here cause there are 2 differents "actions":
  • "action" in the context of your game.
  • "action" in the context of your BGA interface.
During your multipleactiveplayer turn, I see only 1 possibles action, which is "propose an action" (ie: propose one of the 3 available actions).

So I would do the following:

Code: Select all

30 => array(
          "name" => "teamTurn",
          "description" => clienttranslate('${you} propose an Action or answer others\' proposals'),
          "descriptionmyturn" => clienttranslate('${you} propose an Action or answer others\' proposals'),
          "type" => "multipleactiveplayer",
          "args" => "argTeamTurn",
          "possibleactions" => array("proposeAction"),
          "transitions" => array("moveAResource" => 40, "solveAChallenge" => 50, "useAPower" => 60, "pass" => 90)
    ),  
Then, in your method "proposeAction", you store actions proposed by each players. Once they all agree, you can call "nextState" with the corresponding actions.

Be careful to make all players active anytime, and do not unactive them when they choose their action: there must always be at least one player active so that the time can decreases.

Cheers,

Re: How multiactiveplayer states work

Posted: 25 September 2014, 00:29
by adela82
Thank you!

So how can I activate all players? In the documentation you can read:
$this->gamestate->setAllPlayersMultiactive()
With this method, all playing players are made active.
Usually, you use this method at the beginning (ex: "st" action method) of a multiplayer game state when all players have to do some action.
But In the states file, I never saw a multiactiveplayer action with a defined "st" action method. Should I add 'action' key??:

Code: Select all

30 => array(
          "name" => "teamTurn",
          "description" => clienttranslate('${you} propose an Action or answer others\' proposals'),
          "descriptionmyturn" => clienttranslate('${you} propose an Action or answer others\' proposals'),
          "type" => "multipleactiveplayer",
          "args" => "argTeamTurn",
          "action" => "stTeamTurn",
          "possibleactions" => array("proposeAction"),
          "transitions" => array("moveAResource" => 40, "solveAChallenge" => 50, "useAPower" => 60, "pass" => 90)
    ),  
and then active in that method all my players. And then, when should I deactivate them?

Thanks in advance!

Re: How multiactiveplayer states work

Posted: 28 September 2014, 20:35
by Een
Hi,

Yes, you need to add an action to your multiplayer state.

Example from Tokaido, for the traveler selection phase:

Code: Select all

21 => array(
    	"name" => "multiplayerChooseTraveler",
    	"description" => clienttranslate('All players must choose a traveler'),
    	"descriptionmyturn" => clienttranslate('All players must choose a traveler'),
    	"type" => "multipleactiveplayer",
    	"action" => "stMultiplayerChooseTraveler",
    	"possibleactions" => array( "selectTraveler" ),
    	"transitions" => array( "" => 22 ),
    ),
In the method for this action in your game.php file, you need to make all players active with $this->gamestate->setAllPlayersMultiactive().
This method will be executed only once, when entering your multiactive state.

Then, when a player has performed the game action he needed to in this state (such as selecting a traveler in Tokaido) in the method from your game.php that gets called from your action.php, you need to mark this player as inactive, then call $this->gamestate->updateMultiactiveOrNextState( '' ). As soon as the last player performed his action, this call will get you to the next state.

Hope this explanation is what you needed!

Cheers,
Een