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

Sinatra Scrabble Primary Reqs #4

Open
wants to merge 5 commits into
base: mmr/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,29 @@ build/

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org/"
ruby "2.2.3"

gem "sinatra"
20 changes: 20 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
GEM
remote: https://rubygems.org/
specs:
rack (1.6.4)
rack-protection (1.5.3)
rack
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
tilt (2.0.1)

PLATFORMS
ruby

DEPENDENCIES
sinatra

BUNDLED WITH
1.10.6
2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require "./scrabble_site"
run ScrabbleSite
34 changes: 34 additions & 0 deletions lib/TileBag.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Scrabble
DEFAULT_TILES = {A: 9, B: 2, C: 2, D: 4, E: 12, F: 2, G: 3, H: 2, I: 9, J: 1, K: 1, L: 4, M: 2, N: 6, O: 8, P: 2, Q: 1, R: 6, S: 4, T: 6, U: 4, V: 2, W: 2, X: 1, Y: 2, Z: 1}
class TileBag
attr_reader :tile_quantities
def initialize
@tile_quantities = DEFAULT_TILES.dup
end
def draw_tiles(num)
drawn_tiles = []
if num > self.tiles_remaining
puts "Not enough tiles to pull #{num} tiles!"
else
key_array = @tile_quantities.keys
num.times do
rand_letter = key_array[rand(0..(key_array.length - 1))]
drawn_tiles.push(rand_letter)
@tile_quantities[rand_letter] -= 1
if @tile_quantities[rand_letter] == 0
@tile_quantities.delete(rand_letter)
end
key_array = @tile_quantities.keys
end
end
return drawn_tiles
end
def tiles_remaining
total_tiles = 0
@tile_quantities.values.each do |value|
total_tiles += value
end
return total_tiles
end
end
end
13 changes: 13 additions & 0 deletions lib/dictionary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# require "ruby-dictionary"
#
# module Scrabble
# class WordDictionary
#
# attr_reader :dictionary
#
# @dictionary = Dictionary.from_file('./lib/dictionary.txt')
#
# def self.valid_word?(word)
# end
# end
# end
Loading