Advertisement
here2share

# Escape_By_Camel.py

Jul 2nd, 2019
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.57 KB | None | 0 0
  1. # Escape_By_Camel.py
  2.  
  3. import random
  4. intro = ["Escape By Camel!",
  5.                   "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."]
  6. options = ["A. Drink from your canteen.",
  7.            "B. Ahead moderate speed.",
  8.            "C. Ahead full speed.",
  9.            "D. Stop for the night.",
  10.            "E. Status check.",
  11.            "Q. Quit."]
  12. class game():
  13.     distance_travelled = 0
  14.     natives_distance_travelled = -20
  15.     canteen = 3
  16.     user_input = ""
  17.     game_over = False
  18.     init = True
  19.     camel_tiredness = 0
  20.     thirst = 0
  21.     distance_tracker = 0
  22.     natives_distance_tracker = 0
  23.     travel_type = ""
  24. def display_options():
  25.     if game.init == True:
  26.         for i in intro:
  27.             print i
  28.         print ""
  29.         game.init = False
  30.     for i in options:
  31.         print i
  32.     if game.thirst > 4:
  33.         print "You are thirsty."
  34.     if game.camel_tiredness > 5:
  35.         print "Your camel is getting tired."
  36.     if game.distance_travelled - game.natives_distance_travelled <= 15:
  37.         print "The natives are getting close!"
  38. def get_input():
  39.     user_input = str(raw_input("Your choice? "))
  40.     game.user_input = user_input.upper()
  41. def action_input():
  42.     if game.user_input == "A":
  43.         if game.canteen < 1:
  44.             print "You have no water!\n"
  45.         else:
  46.             drink()
  47.             print "You are refreshed.\n"
  48.     elif game.user_input == "B":
  49.         game.travel_type = "moderate"
  50.         travel()
  51.     elif game.user_input == "C":
  52.         game.travel_type = "full"
  53.         travel()
  54.     elif game.user_input == "D":
  55.         rest()
  56.         print "You rest for the night.\nYour camel is happy.\nThe natives gained {} miles on you.\n".format(game.natives_distance_tracker)
  57.     elif game.user_input == "E":
  58.         print "\nMiles traveled: {}".format(game.distance_travelled)
  59.         print "Drinks in canteen: {}".format(game.canteen)
  60.         print "The natives are {} miles behind you.\n".format(game.distance_travelled - game.natives_distance_travelled)
  61.     elif game.user_input == "Q":
  62.         print "\nBye!"
  63.         game.game_over = True
  64. def travel():
  65.     natives_travel()
  66.     own_travel()
  67.     camel_tiredness_funct()
  68.     thirst_funct()
  69.     print "\nYou traveled {} miles.\n".format(game.distance_tracker)
  70. def camel_tiredness_funct():
  71.     if game.travel_type == "moderate":
  72.         game.camel_tiredness += 1
  73.     elif game.travel_type == "full":
  74.         game.camel_tiredness += random.randint(2, 3)
  75. def natives_travel():
  76.     game.natives_distance_tracker = random.randint(7, 14)
  77.     game.natives_distance_travelled += game.natives_distance_tracker
  78. def own_travel():
  79.     if game.travel_type == "moderate":
  80.         game.distance_tracker = random.randint(7, 14)
  81.         game.distance_travelled += game.distance_tracker
  82.     elif game.travel_type == "full":
  83.         game.distance_tracker = random.randint(10, 20)
  84.         game.distance_travelled += game.distance_tracker
  85. def thirst_funct():
  86.     game.thirst += 1
  87. def drink():
  88.     game.thirst = 0
  89.     game.canteen -= 1
  90. def rest():
  91.     game.camel_tiredness = 0
  92.     natives_travel()
  93. def oasis():
  94.     game.thirst = 0
  95.     game.camel_tiredness = 0
  96.     game.canteen = 3
  97. def checks():
  98.     if game.thirst > 6:
  99.         print "You died of thirst!"
  100.     elif game.camel_tiredness > 8:
  101.         print "Your camel is dead."
  102.     elif game.natives_distance_travelled >= game.distance_travelled:
  103.         print "The natives have caught you!"
  104.     elif game.distance_travelled >= 200:
  105.         print "You have escaped!"
  106.     else:
  107.         oasis_chance = random.randint(1, 20)
  108.         if oasis_chance == 20:
  109.             print "\nYou have found an oasis!\nYou refill your canteen, rest your camel, and are back on your way.\n"
  110.             oasis()
  111.             return
  112.     game.game_over = True
  113.  
  114. done = False
  115. while not done:
  116.     display_options()
  117.     get_input()
  118.     action_input()
  119.     checks()
  120.     done = game.game_over
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement