-
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
Sara and Selam Amperes Scrabble #17
base: master
Are you sure you want to change the base?
Conversation
… plays method. Created test for plays and name.
…sly played words if user has not won the game or returning a boolean (false). Included accompying tests.
…without instance variable
…d within an array of words to a player
…ring word would be returned to the user
…est scoring word in an array of played words
Added tiles() and play_tiles() method
cleaned up formatting
Cleaned up formatting
added comments
ScrabbleWhat We're Looking For
|
if array_of_words.size == 0 | ||
highest_score = nil | ||
elsif array_of_words.size == 1 | ||
highest_score = array_of_words[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.
What about if the only word is invalid?
end | ||
|
||
it 'returns the highest word if there are two words' do | ||
random_arr = ['zzebra','medium'] |
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 vary up the order in these tests so that you can ensure that the order isn't determining the winner (unless it's supposed to).
random_arr = ['zzebra','medium']
highest_of_words = Scrabble::Scoring.highest_score_from(random_arr)
highest_of_words.must_equal 'zzebra'
random_arr = ['medium','zzebra']
highest_of_words = Scrabble::Scoring.highest_score_from(random_arr)
highest_of_words.must_equal 'zzebra'
|
||
describe 'total_score' do | ||
it 'Returns a total score to the user' do | ||
player_name = Scrabble::Player.new("Ada") |
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 test to verify that total_sore
doesn't keep going up after the player wins.
end | ||
|
||
it 'Returns score of word if < 100 ' do | ||
player_name = Scrabble::Player.new ("Ada") |
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.
What about playing invalid words?
end | ||
|
||
it 'Returns false if player has not won' do | ||
player_name = Scrabble::Player.new ("Ada") |
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.
What happens with won?
if the player never played a word?
def draw_tiles(tile_bag) | ||
if @players_plaque.length < MAX_NUM_OF_TILES_ALLOWED | ||
add_tiles = MAX_NUM_OF_TILES_ALLOWED - @players_plaque.length | ||
@players_plaque.concat(tile_bag.draw_tiles(add_tiles)) |
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.
Very good!
player_status = false | ||
total_score = 0 | ||
@array_of_words.each do |word_in_arr| | ||
total_score += Scrabble::Scoring.score(word_in_arr) |
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 already have a total_score
method inside Player
why not use it?
|
||
# If the player has over 100 points, returns true, otherwise returns false | ||
def won? | ||
player_case = false |
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 variable name really doesn't make sense.
|
||
# Returns the highest_scoring_word score | ||
def highest_word_score | ||
return highest_scoring_value = Scrabble::Scoring.score(highest_scoring_word) |
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.
NIIIICE!
random_number = rand(0...tiles_remaining) | ||
@tile_bag.map{|letter_type,letter| | ||
letter.each do |single_letter| | ||
if count == random_number |
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.
The structure you've got here, means that each letter has an equal chance of being drawn. Also after a letter is exhausted you'll continue to pop from the letter
array.
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?