src/GameOfLife/Inputs/BoardEditor/Options/ToggleFieldOption.php
/**
     * Sets a field on the board and displays the updated board or displays an error in case of invalid coordinates.
     *
     * @param int $_x X-Coordinate of the field
     * @param int $_y Y-Coordinate of the field
     *
     * @return Bool Indicates whether the board editor session is finished
     *
     * @throws \Exception The exception when one of the coordinates exceeds the board borders
     */
Sets a field on the board and displays the updated board or displays an error in case of invalid coordinates.
@param int $_x X-Coordinate of the field
@param int $_y Y-Coordinate of the field

@return Bool Indicates whether the board editor session is finished

@throws \Exception The exception when one of the coordinates exceeds the board borders
Sets a field on the board and displays the updated board or displays an error in case of invalid coordinates . @param int $_x X - Coordinate of the field @param int $_y Y - Coordinate of the field @return Bool Indicates whether the board editor session is finished @throws \ Exception The exception when one of the coordinates exceeds the board borders
public function toggleField(int $_x, int $_y): Bool
    {
        $this->parentBoardEditor->checkCoordinate($_x, "X",0, $this->parentBoardEditor->board()->width() - 1);
        $this->parentBoardEditor->checkCoordinate($_y, "Y", 0, $this->parentBoardEditor->board()->height() - 1);
        $currentCellState = $this->parentBoardEditor->board()->getFieldStatus($_x, $_y);
        $this->parentBoardEditor->board()->setField($_x, $_y, !$currentCellState);
        $this->parentBoardEditor->setHighLightField($_x, $_y);
        $this->parentBoardEditor->outputBoard();
        return false;
    }
public function toggleField ( int $ _x , int $ _y ) : Bool { $ this -> parentBoardEditor -> checkCoordinate ( $ _x , " X " , 0 , $ this -> parentBoardEditor -> board ( ) -> width ( ) - 1 ) ; $ this -> parentBoardEditor -> checkCoordinate ( $ _y , " Y " , 0 , $ this -> parentBoardEditor -> board ( ) -> height ( ) - 1 ) ; $ currentCellState = $ this -> parentBoardEditor -> board ( ) -> getFieldStatus ( $ _x , $ _y ) ; $ this -> parentBoardEditor -> board ( ) -> setField ( $ _x , $ _y , ! $ currentCellState ) ; $ this -> parentBoardEditor -> setHighLightField ( $ _x , $ _y ) ; $ this -> parentBoardEditor -> outputBoard ( ) ; return false ; }
Sets a field on the board and displays the updated board or displays an error in case of invalid coordinates.
Sets a field on the board and displays the updated board or displays an error in case of invalid coordinates .