-
Notifications
You must be signed in to change notification settings - Fork 21
Panda Complete #10
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
Open
var114
wants to merge
5
commits into
RubyoffRails:master
Choose a base branch
from
var114:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Panda Complete #10
Changes from 4 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| require 'rubygems' | ||
| require 'bundler/setup' | ||
|
|
||
| require_relative 'db/setup' | ||
| Dir.glob('./models/*').each { |r| require r} | ||
| require "./db/seed" | ||
| #require_relative 'models/page' | ||
| #require_relative 'models/book' | ||
|
|
||
|
|
||
|
|
||
| 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.preview}]" | ||
| puts " - [#{book.current_page.options.last.preview}]" | ||
| puts "What do you want to do? Enter A or B" | ||
|
|
||
| book.input( gets ) | ||
| end | ||
|
|
||
| puts book.current_page.content | ||
|
|
||
| puts book.current_page.conclusion |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| 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 :preview | ||
| t.text :content | ||
| t.integer :parent_id | ||
| t.boolean :starting_point, default: false | ||
| t.boolean :conclusion, default: false | ||
| end | ||
| end | ||
| end | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,14 @@ | ||
| # Cleaning Out | ||
|
|
||
| Page.delete_all | ||
| page = Page.create(starting_point: true, preview: 'Adventure road', content: "you wake up on a road. | ||
| It's foggy and dampy. In your bag is 30 gold pieces and bacon sandwich. Which do you choose?") | ||
| Page.create(conclusion: true, parent_id: page.id, preview: "Go into the Forest", content: "Omg...you just won 30 bags of gold: WINNER") | ||
| Page.create(conclusion: true, parent_id: page.id, preview: "Sail across the River", content: "Shat...you just got ripped to pieces by a clan of hungry paranas. LOSER") | ||
|
|
||
| #forrest = Page.create(conclusion: true, id: forrest.id, preview: '', content '') | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| #id: forrest.id | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,21 @@ | ||
| class Book | ||
|
|
||
| attr_reader :current_page | ||
| attr_reader :current_page | ||
|
|
||
| def initialize(starting_page) | ||
| @current_page = starting_page | ||
| end | ||
| end | ||
|
|
||
| def input(input_string) | ||
| if input_string.chomp == "A" | ||
| @current_page = current_page.options.first | ||
| elsif input_string.chomp == "B" | ||
| @current_page = current_page.options.last | ||
| end | ||
| end | ||
| def input(input_string) | ||
| if input_string.chomp == "A" | ||
| @current_page = current_page.options.first | ||
| elsif input_string.chomp == "B" | ||
| @current_page = current_page.options.last | ||
| end | ||
| end | ||
|
|
||
| def complete_game? | ||
| current_page.conclusion? | ||
| end | ||
| def complete_game? | ||
| current_page.conclusion? | ||
|
|
||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,14 @@ | ||
| class Page < ActiveRecord::Base | ||
|
|
||
| def self.starting_point | ||
| Page.where(starting_point: true).first | ||
| end | ||
|
|
||
| def self.starting_point | ||
| Page.where(starting_point: true).first | ||
| end | ||
|
|
||
| def options | ||
| Page.where(:parent_id => id).limit(2) | ||
| end | ||
|
|
||
| def options | ||
| Page.where(:parent_id => id).limit(2) | ||
| end | ||
| # limit(5) | ||
| # index the pages. instead of doing first/last | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,34 @@ | ||
| require_relative "spec_helper" | ||
|
|
||
| describe Book do | ||
| let!(:page) {Page.create(starting_point: true)} | ||
| subject { Book.new(page) } | ||
| let!(:page) {Page.create(starting_point: true)} | ||
| subject { Book.new(page) } | ||
|
|
||
| it "should have a page" do | ||
| subject.current_page.should eq(page) | ||
| end | ||
| it "should have a page" do | ||
| subject.current_page.should eq(page) | ||
| end | ||
|
|
||
| describe "#input" do | ||
| let!(:option_a) { Page.create(parent_id: page.id)} | ||
| let!(:option_b) { Page.create(parent_id: page.id)} | ||
| describe "#input" do | ||
| let!(:option_a) {Page.create(parent_id: page.id)} | ||
| let!(:option_b) {Page.create(parent_id: page.id)} | ||
|
|
||
| it "should receive input and opens page" do | ||
| subject.input("A") | ||
| subject.current_page.should eq(option_a) | ||
| end | ||
| it "should receive input and opens page" do | ||
| subject.input("B") | ||
| subject.current_page.should eq(option_b) | ||
| end | ||
| it "should receive input and opens page" do | ||
| subject.input("A") | ||
| subject.current_page.should eq(option_a) | ||
| end | ||
| it "should receive input and opens page" do | ||
| subject.input("B") | ||
| subject.current_page.should eq(option_b) | ||
| end | ||
|
|
||
| end | ||
|
|
||
| describe "#complete_game?" do | ||
|
|
||
| it "should know when it's done" do | ||
| subject.stub(:current_page) { stub(:conclusion? => true)} | ||
| subject.complete_game?.should be_true | ||
| end | ||
| end | ||
| end | ||
|
|
||
| describe "#complete_game?" do | ||
| let!(:page) {Page.create(starting_point: true)} | ||
| subject { Book.new(page) } | ||
| it "should know when it's done" do | ||
| subject.stub(:current_page) { stub(:conclusion? => true)} | ||
| subject.complete_game?.should be_true | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| require "rspec" | ||
| require 'bundler/setup' | ||
| require_relative '../db/setup' | ||
| require_relative '../db/setup' | ||
| require_relative "../models/page" | ||
| require_relative "../models/book" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍 for 'shat'
LOL