class Mineswiper::Game

Attributes

board[RW]
name[RW]
player[RW]

Public Class Methods

new(name: "Player1", board: Board.new) click to toggle source
# File lib/mineswiper.rb, line 14
def initialize(name: "Player1", board: Board.new)
  @board = board
  @board.prepared_board
  @player = Player.new(@board)
end

Public Instance Methods

game_over?() click to toggle source
# File lib/mineswiper.rb, line 38
def game_over?
  board.won? || board.lost?
end
play() click to toggle source
# File lib/mineswiper.rb, line 20
def play
  until game_over?
    # binding.pry
    board.parse_input(player.move)
  end

  if board.lost?
    board.all_indices.each do |idx|
      x, y = idx
      board.grid[x][y].hidden = false
    end
    player.display.render
    puts "You lose! BOOOM"
  else
    puts "You win"
  end
end