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

Gabriela's Choose your own adventure game #7

Open
wants to merge 4 commits into
base: 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
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Choose Your Own Adventure
To run this program,

Create a [Choose Your Own Adventure](http://en.wikipedia.org/wiki/Choose_Your_Own_Adventure#Format) game. Submit a pull request to this repository with all the necessary files, and replace this README with a description of your game and how to run it. Make sure to give the user instructions in the game about how to play, get help, etc.
please download adventureStory.txt, gabbyAdventure.rb
must be in the same folder

to run, type: ruby gabbyAdventure.rb
into terminal

Then to go thru the story type 1 or 2, till the end of the story
23 changes: 23 additions & 0 deletions adventureStory.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
0: Start Story!: You wake up on an island You look around a bit and find that you are completely alone on this island. All you have now are the clothes on your back and a Swiss army knife. What do you do now: 1: 2
1: Do you make a S.O.S sign out of wood, in the sand?: You made a S.O.S sign out of wood, and now your swiss army knife is dull. Way to go. And no one has even come to rescue you yet, 2 days after making the sign. You are now very hungry and near the point of dehydration: 3: 4
2: Do you search the island to look for food?: You look for food on the island, and find a couple of fruit and small berries. If you eat them it will sustain you for now but you will still eventually go hungry.: 5: 6
3: Do you fashion some rainwater collection out of some large leaves?: Just as you finish constructing this water collection structure it begins to rain, Luckily for you! You are still very hungry.: 7: 2
4: Do you drink the water from the small lagoon you say on you first day of searching the island?: You drank the water and it is good and you soon fall asleep. But when you wake up, you are in a puddle of your own filth, water must not have been that good: 8: 9
5: Eat all of the things you find?: You are content and the water in the fruit also sates you thirst, but to be on the safe side you construct a structure to collect rain water. But as you are finishing making it your vision starts to get blur and the world flips upside down and things get weird, and then its over. and there is nothing. Death by poison berries: -1: -1
6: Eat only the fruit, toss the berries?: You noticed that the other animals on the island had eaten the fruit and there were old fruit pieces scattered about, but not true of the berries, so you warily don’t eat them. You are satisfied with the fruit. and you are no longer as thirsty: 7: 11
7: You go out into the ocean and see what you can find in the way of food?: You go into the ocean and find it teaming with life, there are lobsters and fish and clams, You grab a couple clams and swim back to land, having now discovered a consistent source of food. You will not starve or dehydrate at least.: 12: 13
8: You fashion some rainwater collection out of some large leaves?: In you tired and sick state, it is very makeshift. And unluckily for you it doesn’t rain, for what feels like forever in you dehydrated state. Bu the next time you awaken there is rain water in the structure and you drink it greedily, and fall asleep again?: 14: 15
9: You drink more of the lagoon water, to sate your increadible thirst?: In your delirium you drink more lagoon water and the next time you fall asleep, you don’t wake up. You die dysentery and dehydration.: -1: -1
11: construct a shelter out of wood?: You put together a makeshift shelter to protect yourself from the rain: 16: 17
12: You find a long sturdy stick on your wandering across the island?: This stick you fashion into a spear to use when fishing, to catch some fish next time, could be used to defend yourself too. You sleep satisfied that you will live to see another day: 18: 19
13: You build a shelter.: You sleep satisfied you will live to see another day, now that you’ve discovered a constant source of food: 20: 19
14: You wake up and there is a coconut next to you and you break it open and drink its contents. You are saved for now, the sickness has passed and you will survive for now.: You make a better water collecting structure and search for food, since are now ravenous: 2: 7
15: You wake up and there is person lying next to you?: you are so happy and relieved that you grab them and hug them closes to you and you cry and soon you fall asleep. When you wake up you and your new friend spend the rest of your lives together just surviving and getting by, all alone. Go insane and eventually die: -1: -1
16: you sleep till morning?: During the night there was a full blown strom!Your shelter structure was not architecturally sound and it collapse with you inside. You die pinned down by a tree limb: -1: -1
17: you wake up in the middle of the night?: There is a storm raging around you and you get out of your makeshift shelter before it crushes you to death. You go in search for shelter under a large tree and fall asleep: 21: 7
18: You go swimming to get your next meal in the morning.: This time you go out into deeper water then you did the first time. And all of a sudden there is a shark and it attacks you! But lucky you fashioned your spear and you manage to kill the shark while its clamped onto your shoulder. You are badly wounded but survive. You drag yourself onto shore and rest after your ordeal. When you wake up there is a row boat coming on shore, filled with people who have come to resuce you. You are saved: -1: -1
19: You see a small boat coming toward you.: Its early in the morning and you see a small boat coming towards you and you are soo relieved!: 22: 23
20: You go swimming in the ocean to get your next meal?: This time you go out into deeper water then you did the first time. And all of a sudden there is a shark and it attacks you! And all you hav is your little knife so, try as you might you cant get away and you only do minimal damage to the shark. Eventually he devours you.: -1: -1
21: You look again for food on the island.: You die of starvation because you can't find any.: -1: -1
22: You go towards the boat and wait for it on the beach?: You wait for them to get close and you notice that they are very strangely dressed, not like anyone you’ve ever seen before anyway. Only too late once they have reached you do you come to find out that these people are Cannibals and that they intend to eat you. And eat you they do, you die: -1: -1
23: You go and hid deep in the island?: You hide and spy on them from afar and realize that they are a very strange group of people, and after searching the island they leave, without finding you, luckily. You continue to carry on, surviving, until one day a large ship sails into view and they spot you and save you! HAPPY DAY: -1: -1
50 changes: 50 additions & 0 deletions gabbyAdventure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
def load_story(path)
story= []
File.open(path) do |file_handle|
file_handle.each_line do |line|
entry= {}
id, choice, full, child1, child2 = line.split(': ')
entry["id"]= id
entry["choice"]= choice
entry["full"]= full
entry["child1"]=child1
entry["child2"]=child2
story.push(entry)
end
end
story
end

def nextline(id)
p story[id].choice
p story[id].full
end


s = load_story('adventureStory.txt')
print "\n Welcome to Gabriela Voll's Choose Your own adventure story \n"
cur=0;

while( s[cur]["child1"].to_i >= 0)
puts "\n#{cur} #{s[cur]["choice"]}"
puts "#{s[cur]["full"]}"
puts "\nYou can either (1) #{ s[ s[cur]["child1"].to_i ]["choice"] }"
puts "or you can (2) #{ s[ s[cur]["child2"].to_i ]["choice"] }"
puts "please type a 1 or a 2"
answer= gets.chomp
while (answer != "1" )&&(answer != "2") do
puts "\n\nYou didnt give me a valid next choice please try again, a 1 or a 2 please"
answer= gets.chomp
end
if answer == "1"
cur=s[cur]["child1"].to_i
puts "you choose #{cur}"
else
cur=s[cur]["child2"].to_i
puts "you choose #{cur}"
end
end

puts "\n #{s[cur]["choice"]}"
puts "#{s[cur]["full"]}"
puts "Game Over"