pub fn init(&mut self, board: Board, info: Option<Info>) {
        if self.state != GameState::Created && self.state != GameState::Stopped {
            panic!("You can initialize new or stopped game only.");
        }
        self.board = Some(board);
        self.info = info;
        self.layout();

        // Print initial screen
        if let Some(ref mut board) = self.board {
            self.output.write(board.get_border().as_bytes()).unwrap();
            if let Some(updates) = board.get_updates() {
                self.output.write(updates.as_bytes()).unwrap();
            }
        }
        if let Some(ref info) = self.info {
            self.output.write(info.get_border().as_bytes()).unwrap();
            if let Some(updates) = info.get_updates() {
                self.output.write(updates.as_bytes()).unwrap();
            }
        }
        self.output.flush().unwrap();

        self.state = GameState::Initialized;
    }
/// Initializes game with board and information area (optional).
///
/// This method sets layout. Board and information will be displayed on the screen.
/// Game state will be set to `GameState::Initialized`.
///
/// # Panics
///
/// This method can be called in `GameState::Created` or `GameState::Stopped` states only.
/// Panics if called in any other state.
///
Initializes game with board and information area (optional).
This method sets layout. Board and information will be displayed on the screen.
Game state will be set to `GameState::Initialized`.
Initializes game with board and information area ( optional ) . This method sets layout . Board and information will be displayed on the screen . Game state will be set to ` GameState :: Initialized ` .
pub fn init(&mut self, board: Board, info: Option<Info>) {
        if self.state != GameState::Created && self.state != GameState::Stopped {
            panic!("You can initialize new or stopped game only.");
        }
        self.board = Some(board);
        self.info = info;
        self.layout();
        // Print initial screen
        if let Some(ref mut board) = self.board {
            self.output.write(board.get_border().as_bytes()).unwrap();
            if let Some(updates) = board.get_updates() {
                self.output.write(updates.as_bytes()).unwrap();
            }
        }
        if let Some(ref info) = self.info {
            self.output.write(info.get_border().as_bytes()).unwrap();
            if let Some(updates) = info.get_updates() {
                self.output.write(updates.as_bytes()).unwrap();
            }
        }
        self.output.flush().unwrap();
        self.state = GameState::Initialized;
    }
pub fn init ( & mut self , board : Board , info : Option < Info > ) { if self . state != GameState :: Created && self . state != GameState :: Stopped { panic ! ( " " ) ; } self . board = Some ( board ) ; self . info = info ; self . layout ( ) ; // Print initial screen if let Some ( ref mut board ) = self . board { self . output . write ( board . get_border ( ) . as_bytes ( ) ) . unwrap ( ) ; if let Some ( updates ) = board . get_updates ( ) { self . output . write ( updates . as_bytes ( ) ) . unwrap ( ) ; } } if let Some ( ref info ) = self . info { self . output . write ( info . get_border ( ) . as_bytes ( ) ) . unwrap ( ) ; if let Some ( updates ) = info . get_updates ( ) { self . output . write ( updates . as_bytes ( ) ) . unwrap ( ) ; } } self . output . flush ( ) . unwrap ( ) ; self . state = GameState :: Initialized ; }
Initializes game with board and information area (optional).
Initializes game with board and information area ( optional ) .
&mut self
board
Board
info
Option<Info>
&mut self
board
Board
info
Option<Info>
panics
This method can be called in `GameState::Created` or `GameState::Stopped` states only.
Panics if called in any other state.
This method can be called in ` GameState :: Created ` or ` GameState :: Stopped ` states only . Panics if called in any other state .