Example #1
0
 /**
  * Prepare a Grid object to be renderized.
  *
  * @param ModelBaseGrid $grid
  */
 public function prepare(ModelBaseGrid $grid)
 {
     $gridArray = $grid->getGrid();
     $output = '';
     foreach ($gridArray as $yPosition => $xPositions) {
         $output = $this->getHeaderTableFromKeyArray($output, $xPositions);
         $output = $this->getLineValues($output, $yPosition, $xPositions);
     }
     $this->output = "<pre>{$output}</pre>";
 }
Example #2
0
 /**
  * Prepares the grid to be used.
  */
 public function buildGrid()
 {
     parent::buildGrid();
     $shipBattleship = new Battleship();
     $shipDestroyer1 = new Destroyer();
     $shipDestroyer2 = new Destroyer();
     $shufflerShips = new Shuffle();
     $this->addShip($shipBattleship);
     $this->addShip($shipDestroyer1);
     $this->addShip($shipDestroyer2);
     $shufflerShips->setGrid($this->grid);
     $shufflerShips->shuffleShip($shipBattleship->getSquares(), 1);
     $shufflerShips->shuffleShip($shipDestroyer1->getSquares(), 2);
     $shufflerShips->shuffleShip($shipDestroyer2->getSquares(), 3);
     $this->grid = $shufflerShips->getGrid();
 }