public function status() { $channel = $this->event->getRequest()->getSource(); if (!$this->current_game) { $this->event->addResponse(Response::notice($channel, 'There is no game active.')); return; } $this->event->addResponse(Response::notice($channel, 'There is a game active, started by ' . $this->current_game->getGameOwner()->getName() . '.')); $player_names = $this->getCurrentGamePlayerNames(); if (!$this->current_game->hasStarted()) { $this->event->addResponse(Response::notice($channel, 'The game hasn\'t started yet, and we\'re still in the joining phase.')); $this->event->addResponse(Response::notice($channel, 'So far, ' . join(', ', $player_names) . ' have joined the game.')); return; } $player = $this->current_game->getCurrentPlayer(); $this->event->addResponse(Response::notice($channel, 'The game has started, and we\'re waiting on ' . $player->getName() . ' to ' . ($player->alreadyRolled() ? 'select dice to keep' : 'roll') . '.')); if ($this->current_game->getTieCounter() > 1) { $message = 'This is a continuation of a tied game. So, far there\'ve been ' . $this->current_game->getTieCounter() . ' tied games before this one.'; $this->event->addResponse(Response::notice($channel, $message)); } else { if ($this->current_game->getTieCounter() > 0) { $message = 'This is a continuation of a tied game. So, far there\'s been ' . $this->current_game->getTieCounter() . ' tied game before this one.'; $this->event->addResponse(Response::notice($channel, $message)); } } }
/** * @covers \OftBot\Game::roll * @covers \OftBot\Game::keep */ public function testFullTurn() { $game = new Game('creating_player_name'); $game->start(); $player = $game->getCurrentPlayer(); // First roll $game->roll(); $roll = $player->getRoll(); $this->assertCount(6, $roll); $game->keep(array($roll[0], $roll[1])); // Keep the first two die rolled $kept = $player->getKept(); $this->assertCount(2, $kept); $this->assertFalse($player->turnIsComplete()); $this->assertSame(null, $player->getScore()); // Second roll $game->roll(); $roll = $player->getRoll(); $this->assertCount(4, $roll); $game->keep(array($roll[0])); // Keep the first die rolled $kept = $player->getKept(); $this->assertCount(3, $kept); $this->assertFalse($player->turnIsComplete()); $this->assertSame(null, $player->getScore()); // third roll $game->roll(); $roll = $player->getRoll(); $this->assertCount(3, $roll); $game->keep(array($roll[0], $roll[1], $roll[2])); // Keep all 3 die rolled $kept = $player->getKept(); $this->assertCount(6, $kept); $this->assertTrue($player->turnIsComplete()); $this->assertNotSame(null, $player->getScore()); }