Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Panda, Tiger and now Eagle #3

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
Owner

jwo commented Jun 3, 2012

Looks good.

Eagle project. The flow always merges to a winner on the third level.…
… Page and Book classes replaced with a single DB class as I used the class as a...db.

@jwo jwo commented on the diff Jun 20, 2012

+require 'sinatra'
+require 'shotgun'
+require_relative 'db/seed'
+require_relative 'models/db'
+
+enable :sessions
+
+get '/adventure' do
+ @page = DB.starting_point
+ erb :adventure
+end
+
+post '/adventure' do
+ @page = DB.page_with_id(params[:choice_id].to_i)
+
+ if @page.conclusion == true
@jwo

jwo Jun 20, 2012

Owner

Since this is ActiveRecord, you could probably simplify to @page.conclusion?

@jwo jwo commented on the diff Jun 20, 2012

+require 'rubygems'
+require 'bundler/setup'
+require 'sinatra'
+require 'shotgun'
+require_relative 'db/seed'
+require_relative 'models/db'
+
+enable :sessions
+
+get '/adventure' do
+ @page = DB.starting_point
+ erb :adventure
+end
+
+post '/adventure' do
+ @page = DB.page_with_id(params[:choice_id].to_i)
@jwo

jwo Jun 20, 2012

Owner

If I don't select anything, the params[:choice_id] is null, and .to_i becomes 0.... so you get ugliness. Ideally you'd either be OK with 0, or redirect back to tell them to do it right! :)

@jwo jwo commented on the diff Jun 20, 2012

db/seed.rb
+ conclusion: false)
+
+DB.add_page(choice_2d)
+
+choice_3 = DB.new(starting_point: false,
+ preview_a: "",
+ preview_b: "",
+ option_a_id: 0,
+ option_b_id: 0,
+ content: "You find the maiden, take back your sandwich and ride off into the sunset.",
+ winner: true,
+ conclusion: true)
+
+DB.add_page(choice_3)
+
+start_page.option_a_id = choice_1a.id
@jwo

jwo Jun 20, 2012

Owner

Since this is an eagle project.... I probably would have a method on start_page something like:

def add_choice!(choice)
  options << choice
end

Or something... Seems like MAYBE there's too much being known about the inner workings of the Choice class outside of it.

Owner

jwo commented Jun 20, 2012

Great job here! I enjoyed your adventure in web form!

@jwo jwo closed this Aug 23, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment