Skip to content
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

Updated files from round 1 of pairing #3

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
33971eb
Set up lib and spec directories, and rakefile
alyssahursh Aug 29, 2016
c9d3555
Added Scrabble.rb file
alyssahursh Aug 29, 2016
2b8cc2c
Added blank Scrabble_spec.rb
alyssahursh Aug 29, 2016
ad3ffcd
ADD initial notes on Project
jm-rives Aug 30, 2016
8b0d7bc
Merge pull request #1 from jm-rives/master
alyssahursh Aug 30, 2016
6aa3b83
ADD spec_helper.rb
jm-rives Aug 30, 2016
73e97aa
ADD Scrabble.rb
jm-rives Aug 30, 2016
d0673f8
ADD files from first pairing round
jm-rives Aug 30, 2016
6415bc1
Merge pull request #2 from jm-rives/master
alyssahursh Aug 30, 2016
25fae92
Implemented letter_check tests and method. Wrote word scoring tests.
alyssahursh Aug 30, 2016
8397931
Merge pull request #1 from alyssahursh/master
jm-rives Aug 30, 2016
93c2aab
MERGE Files
jm-rives Aug 30, 2016
d744b4f
Merge pull request #3 from jm-rives/master
jm-rives Aug 30, 2016
54fc170
MERGE conflict fixed
jm-rives Aug 30, 2016
b5ee57b
ADD user input tests
jm-rives Aug 30, 2016
ce58189
ADD tests for alpha char, shortest word, 7 letter word, and same leng…
jm-rives Aug 30, 2016
3aa4ef8
ADD ArgumentError
jm-rives Aug 30, 2016
8a6233e
ADD method for testing 7 letter and shortest word
jm-rives Aug 30, 2016
d115f74
Merge pull request #4 from jm-rives/master
alyssahursh Aug 30, 2016
01c7ee8
Renamed Scrabble.rb to Scoring.rb, created Player.rb file with empty …
alyssahursh Aug 30, 2016
de7b451
Created 11 new tests for the Player class
alyssahursh Aug 30, 2016
6326434
ADD refactored testing files
jm-rives Aug 31, 2016
eb1d73b
ADD TileBag file and specs file
jm-rives Aug 31, 2016
197e59e
ADD Player script and spec
jm-rives Aug 31, 2016
f61f6fd
Worked on improving tests and testing for edge cases
alyssahursh Sep 1, 2016
137bd9e
FIXED alpha test type 1 error
jm-rives Sep 2, 2016
4d4bf9e
Seriously, god only knows
jm-rives Sep 2, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,37 @@
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalisation:
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/
Expand All @@ -33,3 +48,4 @@ build/

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
.DS_Store
13 changes: 13 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs = ["lib", "specs"]
t.warning = false
t.verbose = false
t.test_files = FileList['specs/*_spec.rb']
puts "Running TestTask"
end

task default: :test do
puts "Running my Rakefile"
end
3 changes: 3 additions & 0 deletions Scrabble.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Scrabble

end
9 changes: 9 additions & 0 deletions lib/Game.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

class Scrabble::Game
attr_reader :game_bag

def initialize
@game_bag = Scrabble::TileBag.new
end

end
70 changes: 70 additions & 0 deletions lib/Player.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
require_relative '../Scrabble.rb'

class Scrabble::Player
attr_reader :name, :highest_scoring_word, :total_score, :highest_word_score, :plays, :player_bag, :tiles

def initialize(name)
@name = name
@plays = Array.new
@total_score = 0
@highest_scoring_word = nil
@highest_word_score = 0
@tiles = []

end

def play(word)
if won?
return false
else

tester_tiles = @tiles # Copy of player's tiles to test on without modifying original
if tester_tiles.length != 0
word.each_char do |word_char|
(0...tester_tiles.length).each do |index|
if tester_tiles[index] == word_char
tester_tiles[index] = nil
break
end
raise ArgumentError
end
end
end

# word.each_char do |x|
# puts x
# print @tiles
# puts @tiles.include? x
# if @tiles.include? x == false
# raise ArgumentError
# end
# end

score = Scrabble::Scoring.score(word)
@total_score += score
plays << word
if score > @highest_word_score
@highest_word_score = score
@highest_scoring_word = word
end
return score
end
end

def won?
if @total_score > 100
true
else
false
end
end

def draw_tiles(tile_bag)
tile_hand = tile_bag.draw_tiles(7 - @tiles.length)
tile_hand.each do |x|
@tiles << x
end
return @tiles
end

end
69 changes: 69 additions & 0 deletions lib/Scoring.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
require_relative '../Scrabble.rb'

class Scrabble::Scoring

attr_reader :LETTER_VALUE_ARRAY

@@LETTER_VALUE_ARRAY = {
["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"]=>1,
["D", "G"]=>2,
["B", "C", "M", "P"]=>3,
["F", "H", "V", "W", "Y"]=>4,
["K"]=>5,
["J", "X"]=>8,
["Q", "Z"]=>10
}


def self.letter_check(input)
raise ArgumentError if input =~ /[[:digit:][:punct:][:blank:]]/ || input.length != 1
@@LETTER_VALUE_ARRAY.each do |key, value|
if key.include? input
return value
end
end
end

def self.score(word)
raise ArgumentError if word =~ /[[:digit:][:punct:][:blank:]]/ || word.length == 0
score = 0
word.upcase.each_char do |letter|
score += letter_check(letter)
end
is_seven_or_more(word) ? score += 50 : nil
return score
end

def self.highest_score_from(array_of_words)
high_score = 0
high_score_word = nil
# Evaluate .max method instead?
array_of_words.each do |word|
current_word_score = score(word)
if current_word_score == high_score
if word.length == 7 && high_score_word.length != 7
high_score_word = word
high_score = current_word_score
elsif word.length < high_score_word.length
high_score_word = word
high_score = current_word_score
end
end

if current_word_score > high_score
high_score = current_word_score
high_score_word = word
end
end
return high_score_word
end

def self.is_seven_or_more(word)
if word.length >= 7
return true
end
return false
end
end

#puts Scrabble::Scoring.score("QQQQQQQQ")
36 changes: 36 additions & 0 deletions lib/TileBag.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require_relative '../Scrabble.rb'


class Scrabble::TileBag
attr_reader :bag

def initialize
@bag = ["A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B",
"C", "C", "D", "D", "D", "D", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "F", "F",
"G", "G", "G", "H", "H", "I", "I", "I", "I", "I", "I", "I", "I", "I", "J", "K",
"L", "L", "L", "L", "M", "M", "N", "N", "N", "N", "N", "N", "O", "O", "O", "O", "O", "O", "O", "O",
"P", "P", "Q", "R", "R", "R", "R", "R", "R", "S", "S", "S", "S", "T", "T", "T", "T", "T", "T",
"U", "U", "U", "U", "V", "V", "W", "W", "X", "Y", "Y", "Z"]
end

def draw_tiles(num)
if num <= 0 || num > 7 || num.class != Fixnum
raise ArgumentError
else
tile_hand = []
@bag.shuffle!
num.times do
tile_hand << @bag.pop
end
return tile_hand
end
end

def tiles_remaining
return @bag.length
end


end

puts Scrabble::TileBag.new.bag.length
13 changes: 13 additions & 0 deletions sandbox/array_hash_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
hello = {["A", "E"]=> 1, ["F", "G"]=> 2}

# def finder(input)
def find_value(input)
hello = {["A", "E"]=> 1, ["F", "G"]=> 2}
hello.each do |key, value|
if key.include? input
return value
end
end
end

puts find_value("A")
87 changes: 87 additions & 0 deletions scrabble_notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
==================
==== key =====
==================

alyssahursh = Alyssa (remote repo host)
jm-rives = Joanna M. Rives (remote repo collaborater)

TODO: handle = assigns task to specific dev

[ ] = requirement for current test suite
{ } = needs test suite

######################
### Learning Goals ###
######################

[ ] Use Test Driven Development (TDD) to write tests and code in parallel
[ ] Create class and instance methods according to requirements
[ ] Utilize Single Responsibility Principle to reduce code dependencies
[ ] Utilize composition between classes, where appropriate

#########################
#### Agile Workflow #####
#########################

~ roles will switch every 30 minutes utilizing a timer
~ 5 minute check in after switch
~ feedback will be direct and spoken kindly and plainly

###############################
#### Project Expectations ####
##############################

[x] from project root file
(x) execute specs files by running RAKE { }
[ ] lib should contain
( ) multiple files of ruby classess ( each ruby class gets its own file in lib) { }
(X) module named "Scrabble" encloses entire project { }
[x] Scrable::Scoring class contains data struture to store the individal letter scores as below

Letter Value

A, E, I, O, U, L, N, R, S, T 1
D, G 2
B, C, M, P 3
F, H, V, W, Y 4
K 5
J, X 8
Q, Z 10

[x ] utilize minitest specs format
[x ] organize tests into DESCRIBE blocks
[ ] use require { }
[x ] use require realtive { }
[ ] use include

################
#### WAVE 1 ####
################

[] Scrabble::Scoring class must have >= ** 8 ** specs {-}
( ) contains self.score(word) {-}
< > returns word score {x }
< > word input is a STRING {x }
< > seven letter words recieve a 50 PT BONUS {x }
[ ] self.highest_score_from(array_of_words)
( ) returns the word in the array with the highest score {x }
( ) IF tie
( ) word composed of fewest tiles wins {x }
UNLESS
( ) top score is a tie between multiple words and one 7 letter word {x }
THEN
7 letter word wins
( ) IF multiple words of == tile length and multiple words of == score {x }
Then first word in array wins


#####################
#### END WAVE 1 ####
####################





*** DO ADVANCE TO NEXT REQUIREMENT TIER UNTIL MVP MET AND TEST ALL GREEN ***

Loading