Sha256: b50ca1c3952a5aaf6e79dfea7902bafeb7d7b99a91a69e89284197af37e19bea
Contents?: true
Size: 873 Bytes
Versions: 1
Compression:
Stored size: 873 Bytes
Contents
module MM class Pegs attr_reader :collection_of_pegs #collection_of_pegs is a multi-dimensional array def initialize(args) @collection_of_pegs = args.fetch(:collection_of_pegs) end def retrieve_peg(row, col) if row >= number_of_rows || col >= number_of_cols nil else collection_of_pegs[row][col] end end def current_row(number_of_turns_taken) collection_of_pegs[number_of_turns_taken] end def display_values # reversed so that game appears to be filling itself in from top to bottom collection_of_pegs.reverse.map do |row| row.map do |peg| peg.display_value end end end private def number_of_rows collection_of_pegs.length end def number_of_cols collection_of_pegs[0].length end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
games_bfox-0.6.0 | lib/games/mastermind/pegs.rb |