class Player
Public Class Methods
new(board)
click to toggle source
# File lib/minesweeper.rb, line 213 def initialize(board) @board = board end
Public Instance Methods
take_turn()
click to toggle source
# File lib/minesweeper.rb, line 217 def take_turn until make_move do puts "That didn't work. Try again." end end
Private Instance Methods
make_move()
click to toggle source
# File lib/minesweeper.rb, line 226 def make_move puts "Mark a square as (C)lear\n or (F)lag it as a mine?" print "> " choice = gets.chomp.upcase print "Choose coordinates in the form of x, y: " x, y = gets.chomp.split(',').map{|c| c.to_i } if choice == "F" @board.place_flag(x, y) else @board.mark_clear(x, y) end end