Example #1
0
 public function fireAction()
 {
     $row = filter_input(INPUT_POST, 'row');
     $col = filter_input(INPUT_POST, 'col');
     $view = new \View();
     if (!$row || !$col) {
         $view->dislayJson(array('status' => 0, 'msg' => 'Invalid coordinates!'));
         return;
     }
     //fire
     $status = $this->fire($row, $col);
     $view->grid = $this->board->getGrid();
     $view->symbols = $this->getBoardSymbols();
     $view->rows = $this->getRowsNames();
     $view->cols = $this->getColsNames();
     //Get the html for the board
     ob_start();
     $view->display('Web/board');
     $html = ob_get_contents();
     ob_clean();
     $data = array('status' => 1, 'msg' => $this->getMessageByStatus($status), 'html' => $html, 'tries' => $this->board->getTries());
     $view->dislayJson($data);
     //Reset the game if it's over
     if ($this->isGameOver()) {
         $this->reset();
     }
 }