Пример #1
0
 /**
  * Starts gameplay.
  */
 public function play()
 {
     if ($this->getSessionData()) {
         if (!empty($this->userInput)) {
             $this->makeShot();
             if ($this->board->allShipsSunk()) {
                 $this->endGame();
             }
         }
     } else {
         $this->initGame();
     }
     $this->setOutputData();
     $this->setSessionData();
     $this->cheatMode = false;
 }
Пример #2
0
 public function testAllShipsSunk()
 {
     $board = new Board(10);
     $this->assertEmpty($board->getShips());
     $board->addShip(new Ship('Submarine', 3));
     $this->assertFalse($board->allShipsSunk());
 }