lib/reversi/game.rb
def check_move(color)
      blank_diff = @status[:none].size - @board.count_disks(Reversi::Board::DISK[:none])

      case blank_diff
      when 1
        if (@board.count_disks(Reversi::Board::DISK[color]) - @status[color].size) < 2
          raise MoveError, "A player must flip at least one or more opponent's disks."
        end
      when 0
        unless (@board.count_disks(Reversi::Board::DISK[:black]) - @status[:black].size) == 0 &&
               (@board.count_disks(Reversi::Board::DISK[:white]) - @status[:white].size) == 0
          raise MoveError, "When a player can't make a valid move, you must not place a new disk."
        end
      else
        raise MoveError, "A player must place a new disk on the board."
      end
    end
# Checks a move to make sure it is valid.
#
# @raise [MoveError] Error is raised when a player make an invalid move.
Checks a move to make sure it is valid.
Checks a move to make sure it is valid .
def check_move(color)
      blank_diff = @status[:none].size - @board.count_disks(Reversi::Board::DISK[:none])
      case blank_diff
      when 1
        if (@board.count_disks(Reversi::Board::DISK[color]) - @status[color].size) < 2
          raise MoveError, "A player must flip at least one or more opponent's disks."
        end
      when 0
        unless (@board.count_disks(Reversi::Board::DISK[:black]) - @status[:black].size) == 0 &&
               (@board.count_disks(Reversi::Board::DISK[:white]) - @status[:white].size) == 0
          raise MoveError, "When a player can't make a valid move, you must not place a new disk."
        end
      else
        raise MoveError, "A player must place a new disk on the board."
      end
    end
def check_move ( color ) blank_diff = @status [ :none ] . size - @board . count_disks ( Reversi :: Board :: DISK [ :none ] ) case blank_diff when 1 if ( @board . count_disks ( Reversi :: Board :: DISK [ color ] ) - @status [ color ] . size ) < 2 raise MoveError , "A player must flip at least one or more opponent's disks." end when 0 unless ( @board . count_disks ( Reversi :: Board :: DISK [ :black ] ) - @status [ :black ] . size ) == 0 && ( @board . count_disks ( Reversi :: Board :: DISK [ :white ] ) - @status [ :white ] . size ) == 0 raise MoveError , "When a player can't make a valid move, you must not place a new disk." end else raise MoveError , "A player must place a new disk on the board." end end
Checks a move to make sure it is valid.
Checks a move to make sure it is valid .
[MoveError] Error is raised when a player make an invalid move.
[ MoveError ] Error is raised when a player make an invalid move .
color