Slackwolf\Game\Game::assignRoles PHP Method

assignRoles() public method

Assigns each user in the game to a role.
public assignRoles ( )
    public function assignRoles()
    {
        $players = $this->roleStrategy->assign($this->lobbyPlayers, $this->optionsManager);
        foreach ($players as $player) {
            $this->livingPlayers[$player->getId()] = $player;
            $this->originalPlayers[$player->getId()] = $player;
            if ($player->role->isRole(Role::WITCH)) {
                $this->setWitchHealingPotion(1);
                $this->setWitchPoisonPotion(1);
            }
        }
    }

Usage Example

Example #1
0
 protected function setUp()
 {
     parent::setUp();
     $gameId = "G0H6N0ABH";
     $players = array('Bob', 'Alice', 'Fred', 'George', 'Tim', 'Joe', 'Jim', 'Sally', 'Mary');
     //    $bob = new $this->getMockBuilder("\Slack\User");
     //    $this->getMockWithoutInvokingTheOriginalConstructor('\Slack\User');
     //    $optionsManager = new OptionsManager();
     //
     //    echo $optionsManager->getOptionValue("changevote") . "\n";
     //
     //    echo $optionsManager->getOptionValue("role_seer") . "\n";
     $this->strat = new Classic();
     $theGame = new Game($gameId, $players, $this->strat);
     $theGame->assignRoles();
 }