-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ampers - Abinnet + Lily - Scrabble #4
base: master
Are you sure you want to change the base?
Conversation
ScrabbleWhat We're Looking For
|
lib/scoring.rb
Outdated
end | ||
|
||
def self.highest_score_from(array_of_words) | ||
max_points = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method breaks when given two words, both with the same score but the 2nd one has 7 letters. Instead of returning the 7-letter-word it returns the 1st word in case of a tie, every time.
specs/scoring_spec.rb
Outdated
end | ||
|
||
it 'if tied, prefer a word with 7 letters' do | ||
Scrabble::Scoring.highest_score_from(["aaaaaad", "qqqqqj"]).must_equal "aaaaaad" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only tests that the 7-letter word wins, if it comes first in the array.
To test it adequately you'd need to also test:
Scrabble::Scoring.highest_score_from(["qqqqqj", "aaaaaad"]).must_equal "aaaaaad"
specs/scoring_spec.rb
Outdated
end | ||
|
||
it 'if tied and no word has 7 letters, prefers the word with fewer letters' do | ||
Scrabble::Scoring.highest_score_from(["qqqqqq", "zxd"]).must_equal "qqqqqq" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at the description here! The word with more letters is winning!
Like above you should also scramble the order.
end | ||
|
||
it 'returns the first word of a tie with same letter count' do | ||
Scrabble::Scoring.highest_score_from(["adbf", "egch"]).must_equal "adbf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again swapping around the order is needed.
def self.score(word) | ||
@word_array = word.upcase.split("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, but can you think of a more efficient data structure to hold the point values?
player_1 = Scrabble::Player.new("Isabel") | ||
player_1.tiles.must_equal [] | ||
player_1.draw_tiles(game_1) | ||
player_1.tiles_hand.length.must_equal 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also have some way to test that the correct letters were removed from the tilebag and placed in the player's hand.
|
||
describe 'draw_tiles' do | ||
it 'can fill hand to 7 tiles' do | ||
game_1 = Scrabble::TileBag.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test hasn't changed from above.
describe 'initialize' do | ||
it 'correctly initializes a bag of tiles' do | ||
game_1 = Scrabble::TileBag.new | ||
game_1.tile_bag["C"].must_equal 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More testing required.
end | ||
|
||
it 'removes random tiles from tile_bag' do | ||
game_1 = Scrabble::TileBag.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good
# end | ||
|
||
describe 'tiles_remaining' do | ||
it 'returns number of tiles remaining in bag' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to set sum_control = game_1.tiles_remaining
then draw and then compare the difference.
Scrabble
Congratulations! You're submitting your assignment.
Comprehension Questions
score
method in theScoring
class a class method instead of an instance method?Enumerable
mixin? If so, where and why was it helpful?