class Game

Attributes

board[R]
player[R]

Public Class Methods

new() click to toggle source
# File lib/minesweeper.rb, line 248
def initialize
  @board = Board.new
  @player = Player.new(@board)
end

Public Instance Methods

play() click to toggle source
# File lib/minesweeper.rb, line 253
def play

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

  endgame
end

Private Instance Methods

endgame() click to toggle source
# File lib/minesweeper.rb, line 270
def endgame
  board.endgame_render
  puts "Oh no! You touched a mine!" if board.game_lost?
  puts "Congratulations! You won!" if board.victory?
  puts "Thanks for playing!"
end
game_over?() click to toggle source
# File lib/minesweeper.rb, line 266
def game_over?
  board.victory? || board.game_lost?
end