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

Choose Your Own Adventure assignment submission #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

codeblahblah
Copy link

@jwo The Book#complete_game? does not work in that it also gives the conclusion as selectable "option".
I.e. You have to be on the actual last page which has Page.create(conclusion: true,... before the loop exits.
Is that why the Eagle Assignment ask to:

  1. Refactor so that the page doesn't have a parent -- instead it stores the id's of its options (option_a_id, option_b_id)?

@codeblahblah
Copy link
Author

@jwo Essentially you're given a choice to "win"?
The game plays out as follows:
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?
your options:
[Go into the forest]
[Walk down the road]
What do you want to do? Enter A or B
[A]
Go into the forest
your options:
[Approach the campfire]
[Sit down to eat your sandwich]
What do you want to do? Enter A or B
[A]
Approach the campfire
your options:
[You're a winner. Get 30 gold pieces!]
[You're a winner. Get 30 gold pieces!]
What do you want to do? Enter A or B
[A]
ADVENTURE COMPLETE
You're a winner. Get 30 gold pieces!
Hope you won!

@@ -4,4 +4,5 @@ gem 'rake'
gem 'rspec'
gem 'activesupport'
gem 'activerecord'
gem "sinatra-activerecord"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is needed

@jwo
Copy link
Member

jwo commented Apr 9, 2014

I.e. You have to be on the actual last page which has Page.create(conclusion: true,... before the loop exits.

Yes, that's the way it is designed. If you ever reach a conclusion, the game should conclude.

Is that why the Eagle Assignment ask to:

  1. Refactor so that the page doesn't have a parent -- instead it stores the id's of its options (option_a_id, option_b_id)?

No. I ask you to do that so that a page could have more than one parent.

@codeblahblah
Copy link
Author

@jwo "Yes, that's the way it is designed. If you ever reach a conclusion, the game should conclude."
What I mean is that you also have to choose the conclusion as an option?
Example:
your options:
[You're a winner. Get 30 gold pieces!]
[You're a winner. Get 30 gold pieces!]
What do you want to do? Enter A or B
[A]

@jwo
Copy link
Member

jwo commented Apr 9, 2014

    puts "  - [#{book.current_page.options.first.content}]"
    puts "  - [#{book.current_page.options.last.content}]"

What happens if there is only one option in the book.current_page.options array?

@codeblahblah
Copy link
Author

@jwo The first and last options are the same object.
At the moment nothing.
Ideally, the loop should be exited...i.e. check complete_game? and exit loop

@jwo
Copy link
Member

jwo commented Apr 9, 2014

  1. You should probably add more options
  2. If you only have 1 object, you could handle that case

@codeblahblah
Copy link
Author

@jwo

  1. I understand that more options means the game lasts longer.
  2. I'm trying to figure out why #complete_game? does not exit the loop automatically. Regardless of the number of options since you're essentially on the next and final turn?

@jwo
Copy link
Member

jwo commented Apr 9, 2014

If you added something like this, it should work the way you want

until book.complete_game? do
  book = book.current_page.options.first if book.current_page.options.count == 1

@codeblahblah
Copy link
Author

@jwo Not working. Results in an infinite loop on the first choice.

@jwo
Copy link
Member

jwo commented Apr 9, 2014

(It's your code, you'll need to make it work)

On Wed, Apr 9, 2014 at 5:27 PM, drammopo [email protected] wrote:

@jwo Not working. Results in an infinite loop on the first choice.

Reply to this email directly or view it on GitHub:
#13 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants