예제 #1
0
 /**
  * Attack coordinates by row/col
  * @param int $row Number of the row
  * @param int $col Number of the column
  * @return int
  */
 protected function fire($row, $col)
 {
     $ship = $this->board->fire($row, $col);
     if ($ship) {
         if ($ship->isSunk()) {
             if ($this->board->isCleared()) {
                 $status = self::STATUS_FINISHED;
             } else {
                 $status = self::STATUS_SUNK;
             }
         } else {
             $status = self::STATUS_HIT;
         }
     } else {
         $status = self::STATUS_MISS;
     }
     $this->setGameStatus($status);
     return $status;
 }