예제 #1
0
파일: GameManager.php 프로젝트: h0ke/OftBot
 protected function doKeep(array $kept)
 {
     $channel = $this->event->getRequest()->getSource();
     $this->current_game->keep($kept);
     if (!$this->current_game->getCurrentPlayer()->turnIsComplete()) {
         $this->doRoll();
         return;
     }
     $message = '@' . $this->current_game->getCurrentPlayer()->getName() . ', that was your last roll.  ';
     if ($this->current_game->getCurrentPlayer()->getScore() > 0) {
         $message .= 'Your final score was ' . $this->current_game->getCurrentPlayer()->getScore() . '.';
     } else {
         $message .= 'You did not qualify.';
     }
     $this->event->addResponse(Response::notice($channel, $message));
     if (!$this->current_game->currentPlayerIsLastPlayer()) {
         $this->current_game->setCurrentPlayerToNextPlayer();
         $this->event->addResponse(Response::notice($channel, '@' . $this->current_game->getCurrentPlayer()->getName() . ', it\'s your turn next.  Type \'@oftbot roll\' to take your first roll.'));
     } else {
         $this->finishGame();
     }
 }
예제 #2
0
파일: GameTest.php 프로젝트: h0ke/OftBot
 public function testCurrentPlayerIsLastPlayer()
 {
     $game = new Game('creating_player_name');
     $game->addPlayer('new_player_one');
     $game->addPlayer('new_player_two');
     $game->start();
     $this->assertFalse($game->currentPlayerIsLastPlayer());
     $game->setCurrentPlayerToNextPlayer();
     $this->assertFalse($game->currentPlayerIsLastPlayer());
     $game->setCurrentPlayerToNextPlayer();
     $this->assertTrue($game->currentPlayerIsLastPlayer());
 }