Sha256: f79df712ca5642c89145ffb4b5ae89cc3648afe1bc572eac790ff007b4c867c2

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

module MM
  class Board
    attr_accessor :number_of_rows, :number_of_cols, :pegs, :result_pegs

    def initialize(args = {})
      @number_of_rows = args[:number_of_rows]
      @number_of_cols = args[:number_of_cols]
      @pegs = args[:pegs]
      @result_pegs = args[:result_pegs]
    end

    def change_peg(row, col, new_value)
      peg_to_change = retrieve_peg(row, col)
      peg_to_change.change_value(new_value)
    end

    def display_values
      pegs.display_values
    end

    def result_values
      result_pegs.display_values
    end

    def pegs_current_row(number_of_turns_taken)
      pegs.current_row(number_of_turns_taken)
    end

    def result_pegs_current_row(number_of_turns_taken)
      result_pegs.current_row(number_of_turns_taken)
    end

    private
      def retrieve_peg(row, col)
        return pegs.retrieve_peg(row, col)
      end

      #result_pegs is an instance of pegs
      def retrieve_result_peg(row, col)
        return result_pegs.retrieve_peg(row,col)
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
games_bfox-0.4.0 lib/games/mastermind/board.rb
games_bfox-0.3.0 lib/games/mastermind/board.rb
games_bfox-0.2.0 lib/games/mastermind/board.rb