src/GameOfLife/Outputs/BoardEditorOutput.php
/**
     * Print the board to the console and highlights the cell at ($_curX | $_curY) if both values are set.
     *
     * @param Board $_board Current board
     * @param Bool $_isFinalBoard Indicates whether the simulation ends after this output
     * @param Integer $_highLightX X-Coordinate of the cell that shall be highlighted
     * @param Integer $_highLightY Y-Coordinate of the cell that shall be highlighted
     * @param array $_selectionCoordinates The selection coordinates
     */
Print the board to the console and highlights the cell at ($_curX | $_curY) if both values are set.
Print the board to the console and highlights the cell at ( $_curX | $_curY ) if both values are set .
public function outputBoard(Board $_board, Bool $_isFinalBoard = false, int $_highLightX = null, int $_highLightY = null, array $_selectionCoordinates = null)
    {
        $this->additionalSpace = 0;
        if (isset($_highLightX) && isset($_highLightY))
        {
            $this->highLightX = $_highLightX;
            $this->highLightY = $_highLightY;
            $this->isHighLight = true;
            $hasLeftBorder = true;
            if ($_highLightX == 0) $hasLeftBorder = false;
            $hasRightBorder = true;
            if ($_highLightX == $_board->width() - 1) $hasRightBorder = false;
            $this->additionalSpace = $hasLeftBorder + $hasRightBorder;
            $paddingLeft = str_repeat(" ", $_highLightX + $hasLeftBorder);
            $xCoordinateHighLightString = str_pad($paddingLeft . $_highLightX, $_board->width() + $this->additionalSpace);
            echo $this->shellOutputHelper->getCenteredOutputString($xCoordinateHighLightString) . "\n";
        }
        elseif ($_selectionCoordinates && $_selectionCoordinates != array())
        {
            $this->additionalSpace = 2;
            if ($_selectionCoordinates["A"]["x"] == 0) $this->additionalSpace -= 1;
            if ($_selectionCoordinates["B"]["x"] == $_board->width() - 1) $this->additionalSpace -= 1;
        }
        echo $this->getBoardContentString($_board, "║", "o", " ", $_selectionCoordinates);
        $this->isHighLight = false;
    }
public function outputBoard ( Board $ _board , Bool $ _isFinalBoard = false , int $ _highLightX = null , int $ _highLightY = null , array $ _selectionCoordinates = null ) { $ this -> additionalSpace = 0 ; if ( isset ( $ _highLightX ) && isset ( $ _highLightY ) ) { $ this -> highLightX = $ _highLightX ; $ this -> highLightY = $ _highLightY ; $ this -> isHighLight = true ; $ hasLeftBorder = true ; if ( $ _highLightX == 0 ) $ hasLeftBorder = false ; $ hasRightBorder = true ; if ( $ _highLightX == $ _board -> width ( ) - 1 ) $ hasRightBorder = false ; $ this -> additionalSpace = $ hasLeftBorder + $ hasRightBorder ; $ paddingLeft = str_repeat ( " " , $ _highLightX + $ hasLeftBorder ) ; $ xCoordinateHighLightString = str_pad ( $ paddingLeft . $ _highLightX , $ _board -> width ( ) + $ this -> additionalSpace ) ; echo $ this -> shellOutputHelper -> getCenteredOutputString ( $ xCoordinateHighLightString ) . " \n " ; } elseif ( $ _selectionCoordinates && $ _selectionCoordinates != array ( ) ) { $ this -> additionalSpace = 2 ; if ( $ _selectionCoordinates [ " A " ] [ " x " ] == 0 ) $ this -> additionalSpace -= 1 ; if ( $ _selectionCoordinates [ " B " ] [ " x " ] == $ _board -> width ( ) - 1 ) $ this -> additionalSpace -= 1 ; } echo $ this -> getBoardContentString ( $ _board , " ║", " " , " " , $ s electionCoordinates); $ this -> isHighLight = false ; }
Print the board to the console and highlights the cell at ($_curX | $_curY) if both values are set.
Print the board to the console and highlights the cell at ( $_curX | $_curY ) if both values are set .
// Output the X-Coordinate of the highlighted cell above the board