def check?(color, proposed_manifest = @piece_locations, recurse_for_checkmate = false)
      enemy_attack_vectors  = {}
      player_attack_vectors = {}

      king_loc    = []
      enemy_color = opposing_color(color)

      proposed_manifest.each do |piece, details|
        if details[:color] == enemy_color
          enemy_attack_vectors[piece] = possible_moves(piece, proposed_manifest)

        elsif details[:color] == color
          begin
            player_attack_vectors[piece] = possible_moves(piece, proposed_manifest)
          rescue
            # TODO: Fix possible_moves() so it doesn't throw exceptions
            # This happens because it is searching board for where pieces
            # will be, as as a result some pieces are nil
          end
        end

        king_loc = piece if details[:color] == color && details[:type] == :king
      end

      danger_vector  = enemy_attack_vectors.values.flatten.uniq
      defence_vector = player_attack_vectors.values.flatten.uniq
      king_positions = possible_moves(king_loc, proposed_manifest)

      # The King is in the attackable locations by the opposing player
      return false unless danger_vector.include? king_loc

      # If all the positions the king piece can move to is also attackable by the opposing player
      if recurse_for_checkmate && (king_positions - danger_vector).empty?

        is_in_check = []
        player_attack_vectors.each do |piece_index, piece_valid_moves|
          piece_valid_moves.each do |possible_new_location|
            # Check if board is still in check after piece moves to its new location
            @new_piece_locations = @piece_locations.clone
            @new_piece_locations[possible_new_location] = @new_piece_locations[piece_index]
            @new_piece_locations[piece_index] = {
              type:   nil,
              number: nil,
              color:  nil
            }

            is_in_check << check?(color, @new_piece_locations)
          end
        end

        return false if is_in_check.include?(false)
        @checkmate = true
      end

      true
    end
def check?(color, proposed_manifest = @piece_locations, recurse_for_checkmate = false)
      enemy_attack_vectors  = {}
      player_attack_vectors = {}

      king_loc    = []
      enemy_color = opposing_color(color)

      proposed_manifest.each do |piece, details|
        if details[:color] == enemy_color
          enemy_attack_vectors[piece] = possible_moves(piece, proposed_manifest)

        elsif details[:color] == color
          begin
            player_attack_vectors[piece] = possible_moves(piece, proposed_manifest)
          rescue
            # TODO: Fix possible_moves() so it doesn't throw exceptions
            # This happens because it is searching board for where pieces
            # will be, as as a result some pieces are nil
          end
        end

        king_loc = piece if details[:color] == color && details[:type] == :king
      end

      danger_vector  = enemy_attack_vectors.values.flatten.uniq
      defence_vector = player_attack_vectors.values.flatten.uniq
      king_positions = possible_moves(king_loc, proposed_manifest)

      # The King is in the attackable locations by the opposing player
      return false unless danger_vector.include? king_loc

      # If all the positions the king piece can move to is also attackable by the opposing player
      if recurse_for_checkmate && (king_positions - danger_vector).empty?

        is_in_check = []
        player_attack_vectors.each do |piece_index, piece_valid_moves|
          piece_valid_moves.each do |possible_new_location|
            # Check if board is still in check after piece moves to its new location
            @new_piece_locations = @piece_locations.clone
            @new_piece_locations[possible_new_location] = @new_piece_locations[piece_index]
            @new_piece_locations[piece_index] = {
              type:   nil,
              number: nil,
              color:  nil
            }

            is_in_check << check?(color, @new_piece_locations)
          end
        end

        return false if is_in_check.include?(false)
        @checkmate = true
      end

      true
    end
Return whether the player of a specified color has their king currently in check
 by checking the attack vectors of all the opponents players against the king location
 Also, check whether king currently in check, has all of their valid moves within
 their opponents attack vectors, and therefore are in checkmate (@checkmate)