Skip to content

Instantly share code, notes, and snippets.

@T31337
Last active August 29, 2015 14:06
Show Gist options
  • Save T31337/207907953b79ee8edfc1 to your computer and use it in GitHub Desktop.
Save T31337/207907953b79ee8edfc1 to your computer and use it in GitHub Desktop.
Choose Your Own Adventure Game
#!/usr/bin/env python3
import random
import time
import sys
class MyAdventure:
def loseGame(self):
print(
"""
[ GameOver! ]
[ You self.lose :( ]
|%s Will Always Be Remembered!|
|A Brave A Adventurer!|
""" % self.name
)
input('Press Retrun/Enter To Exit...')
sys.exit()
def pause(self):
print('Press The Enter/Retrn Key To Continue...')
input()
def SetUpMyGame(self):
print(
'''
-----------
| Welcome: |
-----------------------------------------------------------
| |
| First, We Must Get Some Basic Inormation About Our Hero. |
| |
| I Will Only Ask A Few Simple Questions, |
| Then We Can Begin Our Game, Okay? |
| |
-----------------------------------------------------------
'''
)
self.gender = None
self.name = None
time.sleep(3)
self.gender = 'None'
correct = 'No'
while correct != 'y' or correct != 'Y':
while (self.gender != 'b' or self.gender != 'B') or (self.gender != 'g' or self.gender != 'G'):
print('Is Our Hero A Boy Or A Girl?')
self.gender = input('B For Boy or G For Girl: ')
if self.gender == 'b' or self.gender == 'B' or self.gender == 'g' or self.gender == 'G':
break
while self.name == '' or self.name == None or self.name== ' ':
self.name = input('By Whay name Is Our Hero Known As?\n')
if self.gender == 'b' or self.gender == 'B':
print('Our Hero Is A Boy, By The Name Of:',self.name)
else:
print('Our Hero Is A Girl, By The Name Of:',self.name)
print('Is This Correct? Y/N')
correct = input()
if correct == 'Y' or correct == 'y':
break
else:
self.name = None
self.intro()
def win(self):
print(
"""
-------------------------
|You win! Congratulations!|
-------------------------
| (> ' ' )> ! <( ' ' <) |
-------------------------
%s Is A Great Adventurer!
""" % self.name
)
input('Press Enter/Return To Exit...')
sys.exit()
def intro(self):
print(
"""
---------------------------------------------------
|Our Hero Must Get To The Town Of KnoppoxVille, |
|There Are However Currently Two Ways To Get There, |
|Through The Forest, Or Through The Caves Which Way?|
---------------------------------------------------
"""
)
direction = 0
while direction != 1 or direction != 2:
try:
direction = int(input('1=Forest\n2=Caves\nChoice:> '))
if direction == 1 or direction == 2:
break
except:
print("Try Again!")
if direction == 1:
self.forest()
elif direction == 2:
self.caves()
def forest(self):
direction = 0
print(
'''
-------------------------
|Through The Forest We Go!|
-------------------------------------------
| A Fork Lies In The Road, Left Or Right?|
----------------------------------------
'''
)
while direction != 1 or direction != 2:
try:
direction = int(input('1 = Left\n2 = Right\nChoice:> '))
if direction == 1 or direction == 2:
break
except:
print("Try Again!")
if direction == 1:
bear = random.randint(1,2)
if bear == 1:
#Encounter Bear
print(
"""
---------------------------------------------------
|Oops! Looks Like You Stumbled Upon A Sleeping Bear!|
| What Will You Do Now? |
---------------------------------------------------
"""
)
#try:
# do = int(input('1=sneak Quiely Around The Bear\n2=Kill The Bear With Your Mighty Sword!\n3=Go Back And Take The Other Path\nChoice:> '))
#except:
# print("Try Again!")
while do != 1 or do != 2 or do != 3:
try:
do = int(input('1=sneak Quiely Around The Bear\n2=Kill The Bear With Your Mighty Sword!\n3=Go Back And Take The Other Path\n> '))
if do == 1 or do == 2 or do == 3:
break
except:
print("Try Again!")
if do == 1:
print(
"""
------------------
|You Sneak Quietly!|
| --------------------------------------
|Luckly, The Bear Is In A Deep Sleep And Didn't Notice You|
---------------------------------------------------------
"""
)
elif do == 2:
print(
"""
----------------------------------
|You Run At The Bear Sword Flairing|
| |
|The Bear Hears You And Is Awakened|
| -----
|You Fight The Bear With All Your Might! |
----------------------------------------
"""
)
lives = random.randint(1,3)
time.sleep(4)
if lives == 1:
#1 in 3 chance of killing The Bear
print(
"""
--------------------
|You Killed The Bear!|
--------------------
"""
)
else:
print(
"""
--------------------
|The Bear Killed You!|
--------------------
"""
)
self.loseGame()
elif do == 3:
donext = 0
print(
"""
---------------------------
|You Encounter A Wild Wolf! |
----------------------------------------
| There Is No Escape, You Must Do Battle!|
----------------------------------------------
|1. Try And Cut It's Head Off! |
|2. Trhow Stones At It In Hopes It Turns Away! |
----------------------------------------------
"""
)
while donext != 1 or donext != 2:
try:
donext = int(input('1=Cut It\'s Head Off!\n2=Throw Stones At It\nChoice:> '))
except:
print("Try Again!")
if donext == 2:
lucky = random.randint(1,2)
if lucky == 1:
print(
"""
---------------------------------------------
|After Sevral Stones Were Thrown At The Wolf, |
|The Wolf Turns And Runs Away! |
---------------------------------------------
"""
)
print(
"""
------------------------------
|The Wolf Lunges At You! |
|You Quickly Sself.wing Your Sword |
------------------------------
"""
)
time.sleep(3)
print(
"""
--------------------------------------------
|You Manage To Cut Off The Head Of The Wolf! |
--------------------------------------------
"""
)
time.sleep(3)
print(
"""
-------------------------------
|You Made It Through The Forest!|
-------------------------------
"""
)
self.win()
elif direction == 2:
time.sleep(3)
print(
"""
-------------------------------
|You Made It Through The Forest!|
-------------------------------
"""
)
self.win()
def caves(self):
print(
"""
------------------------
|Through The Caves We Go!|
------------------------
"""
)
time.sleep(3)
spider = random.randint(1,2)
if spider == 1:
print(
"""
-----------------------------
|You Encounter A Giant Spider!|
-----------------------------
"""
,
"""
:
:
:
/\('')/\
\ /
"""
)
time.sleep(4)
print(
"""
---------------------------
|The Spider Begins To Speak!|
---------------------------------
|I Can Smell A Yummy Sandwitch!|
------------------------------
"""
)
time.sleep(5)
print(
"""
--------------------------------------------
|Tell You What, If You Give Me The Sandwitch,|
|I Will Let You Pass Unharmed, What Say Ye? |
--------------------------------------------
"""
)
choice = 0
while choice != 1 or choice !=2:
try:
choice = int(input('1=Sounds Like A Deal! (Give Sandwitch To Spider?)\n2=No Way! My Sandwich! (Fight The Spider)\nChoice:> '))
if choice == 1 or choice ==2:
break
except:
print("Try Again!")
if choice == 1:
print(
"""
---------------------------------
|Here You Go! (The Spider Smiles) |
---------------------------------
|The Spider Permits You To Pass!|
-------------------------------
"""
)
time.sleep(4)
self.win()
elif choice == 2:
chance = random.randint(1,3)
if chance == 1:
print(
"""
----------------------------------------------
|You Fight The Spider And Sucessfully Slay It! |
----------------------------------------------
"""
)
time.sleep(4)
self.win()
else:
print(
"""
---------------------------
|You Were Slain By A Spider!|
---------------------------
"""
)
time.sleep(3)
self.loseGame()
else:
print(
"""
------------------------------
|You Hear A Frightning Sound...|
------------------------------
"""
)
choice = 0
while choice != 1 or choice != 2:
try:
choice = int(input('1=Investigate The Sound\n2=Ignore The Sound And Keep Going\nChoice:> '))
if choice == 1 or choice == 2:
break
except:
print("Try Again!")
if choice == 1:
#investigate Sound
time.sleep(3)
print(
"""
--------------------------------
|Upon Further Investigation, |
|You Realize What The Sound Is...|
--------------------------------
"""
)
time.sleep(5)
print(
"""
-----------------------------------
|Oh No! The Sound Is A Grizzy Bear! |
-----------------------------------
|The Bear Seems Hungry And Angry... |
--------------------------------------
|You Have Gone Too Far To Turn Back Now|
--------------------------------------
"""
)
choose = 0
while choose != 1 or choose != 2:
try:
choose = int(input('1=Throw Rocks Accross The Cave To Draw The Bear\'s Attention\n2=Attempt To Slay The Bear!'))
if choose == 1 or choose ==2:
break
except:
print("Try Again!")
if choose == 1:
print(
"""
----------------------------------------------------------
|You Trhow Some Rocks On The Other Side Of The Cave... |
|You Are Hiding Behind A Big Rock, The Bear Doesn't See You|
----------------------------------------------------------
"""
)
time.sleep(5)
print(
"""
------------------------------------------------
|The Bear Hears The Rocks And Goes To Investigate|
|You Safley Make It Past The Bear! You Can See |
|A Light At The End Of The Cave! You Run For It! |
------------------------------------------------
"""
)
time.sleep(5)
print(
"""
------------------------------------------
|You Sucessfully Made It Through The Caves!|
------------------------------------------
"""
)
self.win()
if choose == 2:
lucky = random.randint(1,2)
if lucky == 1:
print(
"""
-------------------------------------------
|You Were Able To Sucessfully Slay The Bear!|
-------------------------------------------
| You Made It Through The Caves! |
-------------------------------------------
"""
)
time.sleep(3)
self.win()
if choice == 2:
print(
"""
------------------------------------------
|You Sucessfully Made It Through The Caves!|
------------------------------------------
"""
)
time.sleep(3)
self.win()
game = MyAdventure()
game.SetUpMyGame()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment