Class: Board
- Inherits:
-
Object
- Object
- Board
- Defined in:
- lib/board.rb
Instance Method Summary collapse
-
#initialize(values, letter_multipliers = {}, word_multipliers = {}) ⇒ Board
constructor
A new instance of Board.
- #play(move) ⇒ Object
Constructor Details
#initialize(values, letter_multipliers = {}, word_multipliers = {}) ⇒ Board
Returns a new instance of Board.
2 3 4 5 6 7 |
# File 'lib/board.rb', line 2 def initialize(values, letter_multipliers = {}, word_multipliers = {}) @values = values @letter_multipliers = letter_multipliers @word_multipliers = word_multipliers @history = [] end |
Instance Method Details
#play(move) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/board.rb', line 9 def play(move) index = generate_index(@history) moves = find_moves(move, index) @history << move score = moves.inject(0) { |score, move| score + score_move(move, index) } tiles_used = calculate_tiles_used(move, index) if tiles_used.length == 7 score += 50 end [score, tiles_used] end |