コード例 #1
0
ファイル: Game.php プロジェクト: kminkov/battleships
 /**
  * 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
ファイル: BoardTest.php プロジェクト: vasildakov/Battleships
 public function testAllShipsSunk()
 {
     $board = new Board(10);
     $this->assertEmpty($board->getShips());
     $board->addShip(new Ship('Submarine', 3));
     $this->assertFalse($board->allShipsSunk());
 }