Skip to content
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
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ GEM
i18n (0.6.0)
multi_json (1.3.4)
pg (0.13.2)
rack (1.5.2)
rack-protection (1.5.3)
rack
rake (0.9.2.2)
rspec (2.10.0)
rspec-core (~> 2.10.0)
Expand All @@ -27,6 +30,14 @@ GEM
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
sinatra-activerecord (1.7.0)
activerecord (>= 3.0)
sinatra (~> 1.0)
tilt (1.4.1)
tzinfo (0.3.33)

PLATFORMS
Expand All @@ -38,3 +49,4 @@ DEPENDENCIES
pg
rake
rspec
sinatra-activerecord
13 changes: 5 additions & 8 deletions adventure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
require_relative 'db/setup'
require_relative 'models/page'
require_relative 'models/book'
require_relative "db/seed"

page = Page.create(starting_point: true, content: "You wake up on a road. It's foggy and dampy. In your bag is 30 gold pieces and a bacon sandwich. Which do you choose?")
Page.create(conclusion: true, parent_id: page.id, content: "Go into the forest")
Page.create(conclusion: true, parent_id: page.id, content: "Walk down the road")

book = Book.new(page)
book = Book.new(Page.starting_point)

until book.complete_game? do
puts book.current_page.content
puts "your options: "
puts " - [#{book.current_page.options.first.content}]"
puts " - [#{book.current_page.options.last.content}]"
puts "What do you want to do? Enter A or B"

book.input( gets )

end
Expand All @@ -30,6 +27,6 @@
puts "------------------------------------------"


puts book.current_page.content
puts book.current_page.content

puts "hope you won!"
puts "Hope you won!"
6 changes: 0 additions & 6 deletions config/database.yml.sample

This file was deleted.

16 changes: 8 additions & 8 deletions db/migrate/001_creates_page.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class CreatesPage < ActiveRecord::Migration
def change
create_table :pages do |t|
t.text :content
t.integer :parent_id
t.boolean :starting_point, default: false
t.boolean :conclusion, default: false
end
end
def change
create_table :pages do |t|
t.text :content
t.integer :parent_id
t.boolean :starting_point, default: false
t.boolean :conclusion, default: false
end
end
end
10 changes: 10 additions & 0 deletions db/seed.rb
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# Cleaning Out
Page.delete_all

start = Page.create(starting_point: true, content: "You wake up on a road. It's foggy and dampy. In your bag is 30 gold pieces and a bacon sandwich. Which do you choose?")
forest = Page.create(conclusion: false, parent_id: start.id, content: "Go into the forest")
road = Page.create(conclusion: false, parent_id: start.id, content: "Walk down the road")

campfire = Page.create(conclusion: false, parent_id: forest.id, content: "Approach the campfire")
sandwich = Page.create(conclusion: false, parent_id: forest.id, content: "Sit down to eat your sandwich")
Page.create(conclusion: true, parent_id: campfire.id, content: "You're a winner. Get 30 gold pieces!")
Page.create(conclusion: true, parent_id: sandwich.id, content: "Eaten by sharks!? bummer!")
2 changes: 1 addition & 1 deletion models/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(starting_page)
end

def input(input_string)
if input_string.chomp == "A"
if input_string.chomp == "A"
@current_page = current_page.options.first
elsif input_string.chomp == "B"
@current_page = current_page.options.last
Expand Down
1 change: 1 addition & 0 deletions rakefile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require "bundler/setup"

require 'rspec/core/rake_task'
require 'active_record'

desc 'Default: run specs.'
task :default => :spec
Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "rspec"
require 'rspec'
require 'bundler/setup'
require_relative '../db/setup'
require_relative "../models/page"
require_relative "../models/book"
require_relative '../models/page'
require_relative '../models/book'