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

Rrs/master #19

Open
wants to merge 4 commits into
base: rrs/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.rb'
run SinatraScrabble
70 changes: 70 additions & 0 deletions lib/board.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module Scrabble
MAX_LENGTH = 15
class Board
attr_accessor :board

def initialize
@board = []
initialize_board
end


def placed_word(word, col, row, direction)
word.length times do |n|
if direction == :horizontal
if horizonal_available?(word, col, row) #return true even if one of the letters located
placed_word_horizontal(word, col, row) #check if there's a letter- and use the right amount of letters the user needs
else
puts "There is no place on the board"
break
end
elsif direction == :vertical
if vertical_available?(word, col, row)
placed_word_vertical(word, col, row)
else
puts "There is no place on the board"
break
end
else
raise ArgumentError, "No direction"
end
end
end

def initialize_board
15.times do |row|
15.times do |col|
@board[row]||= []
@board[row].push("*")
end
end
end

#
# def horizonal_available? (word, col, row) #boolen method
# count = 0
# while @board[col][row]!= nil
# if @board[col][row]!= "*"
# if @board[col][row] == wo
# raise ArgumentError, "Out og board limits"
#
# end

def placed_word_horizontal(word, col, row)
end

def vertical_available?(word, col, row) #boolen method
end

def placed_word_vertical(word, col, row)
end








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


module Scrabble
class Dictionary_Class

def is_valid?(word)
raise ArgumentError if word.class != String
File.open('./lib/dictionary.txt') do |file|
file.any? do |line|
line.include?(word)
end
end
end

end
end
Loading