Class: Game

Inherits:
Object
  • Object
show all
Defined in:
lib/minesweeper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGame

Returns a new instance of Game.



248
249
250
251
# File 'lib/minesweeper.rb', line 248

def initialize
  @board = Board.new
  @player = Player.new(@board)
end

Instance Attribute Details

#boardObject (readonly)

Returns the value of attribute board.



246
247
248
# File 'lib/minesweeper.rb', line 246

def board
  @board
end

#playerObject (readonly)

Returns the value of attribute player.



246
247
248
# File 'lib/minesweeper.rb', line 246

def player
  @player
end

Instance Method Details

#playObject



253
254
255
256
257
258
259
260
261
262
# File 'lib/minesweeper.rb', line 253

def play

  loop do
    board.render
    player.take_turn
    break if game_over?
  end

  endgame
end