Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Escape_By_Camel.py
- import random
- intro = ["Escape By Camel!",
- "You have stolen a camel to make your way across the Great Mobi Desert.", "The natives want their camel back and are chasing you down! Survive your desert trek and outrun the natives."]
- options = ["A. Drink from your canteen.",
- "B. Ahead moderate speed.",
- "C. Ahead full speed.",
- "D. Stop for the night.",
- "E. Status check.",
- "Q. Quit."]
- class game():
- distance_travelled = 0
- natives_distance_travelled = -20
- canteen = 3
- user_input = ""
- game_over = False
- init = True
- camel_tiredness = 0
- thirst = 0
- distance_tracker = 0
- natives_distance_tracker = 0
- travel_type = ""
- def display_options():
- if game.init == True:
- for i in intro:
- print i
- print ""
- game.init = False
- for i in options:
- print i
- if game.thirst > 4:
- print "You are thirsty."
- if game.camel_tiredness > 5:
- print "Your camel is getting tired."
- if game.distance_travelled - game.natives_distance_travelled <= 15:
- print "The natives are getting close!"
- def get_input():
- user_input = str(raw_input("Your choice? "))
- game.user_input = user_input.upper()
- def action_input():
- if game.user_input == "A":
- if game.canteen < 1:
- print "You have no water!\n"
- else:
- drink()
- print "You are refreshed.\n"
- elif game.user_input == "B":
- game.travel_type = "moderate"
- travel()
- elif game.user_input == "C":
- game.travel_type = "full"
- travel()
- elif game.user_input == "D":
- rest()
- print "You rest for the night.\nYour camel is happy.\nThe natives gained {} miles on you.\n".format(game.natives_distance_tracker)
- elif game.user_input == "E":
- print "\nMiles traveled: {}".format(game.distance_travelled)
- print "Drinks in canteen: {}".format(game.canteen)
- print "The natives are {} miles behind you.\n".format(game.distance_travelled - game.natives_distance_travelled)
- elif game.user_input == "Q":
- print "\nBye!"
- game.game_over = True
- def travel():
- natives_travel()
- own_travel()
- camel_tiredness_funct()
- thirst_funct()
- print "\nYou traveled {} miles.\n".format(game.distance_tracker)
- def camel_tiredness_funct():
- if game.travel_type == "moderate":
- game.camel_tiredness += 1
- elif game.travel_type == "full":
- game.camel_tiredness += random.randint(2, 3)
- def natives_travel():
- game.natives_distance_tracker = random.randint(7, 14)
- game.natives_distance_travelled += game.natives_distance_tracker
- def own_travel():
- if game.travel_type == "moderate":
- game.distance_tracker = random.randint(7, 14)
- game.distance_travelled += game.distance_tracker
- elif game.travel_type == "full":
- game.distance_tracker = random.randint(10, 20)
- game.distance_travelled += game.distance_tracker
- def thirst_funct():
- game.thirst += 1
- def drink():
- game.thirst = 0
- game.canteen -= 1
- def rest():
- game.camel_tiredness = 0
- natives_travel()
- def oasis():
- game.thirst = 0
- game.camel_tiredness = 0
- game.canteen = 3
- def checks():
- if game.thirst > 6:
- print "You died of thirst!"
- elif game.camel_tiredness > 8:
- print "Your camel is dead."
- elif game.natives_distance_travelled >= game.distance_travelled:
- print "The natives have caught you!"
- elif game.distance_travelled >= 200:
- print "You have escaped!"
- else:
- oasis_chance = random.randint(1, 20)
- if oasis_chance == 20:
- print "\nYou have found an oasis!\nYou refill your canteen, rest your camel, and are back on your way.\n"
- oasis()
- return
- game.game_over = True
- done = False
- while not done:
- display_options()
- get_input()
- action_input()
- checks()
- done = game.game_over
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement