Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. import random
  2. def quit():
  3. print("You have quit the game.")
  4.  
  5. # status
  6. def status(milesTraveled, distanceNativesTraveled, drinks):
  7. print ("Miles traveled:", milesTraveled)
  8. print ("Drinks in canteen:", drinks)
  9. print ("The natives are", abs(distanceNativesTraveled), "miles behind you.")
  10.  
  11. # Drink from Canteen
  12. def drinkFromCanteen(thirst, drinks):
  13. if drinks > 0:
  14. print("You drink from your canteen.")
  15. drinks -= 1
  16. thirst = 0
  17. else:
  18. print ("Your canteen is empty.")
  19. return thirst, drinks
  20.  
  21. # Move ahead at a moderate speed
  22. def moveMod(milesTraveled, thirst, camelTiredness, distanceNativesTraveled):
  23. print("You move forward at an easy pace.")
  24. user_dist = random.randrange(5, 13)
  25. milesTraveled += user_dist
  26. thirst += 1
  27. camelTiredness += 1
  28. distanceNativesTraveled += random.randrange(7, 15)
  29. distanceNativesTraveled -= user_dist
  30. print ("You have traveled", milesTraveled, "miles.")
  31. return milesTraveled, thirst, camelTiredness, distanceNativesTraveled
  32.  
  33. # Move ahead at Full Speed
  34. def moveFull(milesTraveled, thirst, camelTiredness, distanceNativesTraveled):
  35. print("You rush forward trying to escape the angry natives!")
  36. user_dist = random.randrange(10, 21)
  37. milesTraveled += user_dist
  38. thirst += 1
  39. camelTiredness += random.randrange(1, 4)
  40. distanceNativesTraveled += random.randrange(7, 15)
  41. distanceNativesTraveled -= user_dist
  42. print ("You have traveled", milesTraveled, "miles.")
  43. return milesTraveled, thirst, camelTiredness, distanceNativesTraveled
  44.  
  45. # Stop and rest for the night
  46. def stopRest(camelTiredness, distanceNativesTraveled):
  47. camelTiredness = 0
  48. print ("The camel is happy.")
  49. distanceNativesTraveled += random.randrange(7, 15)
  50. return camelTiredness, distanceNativesTraveled
  51.  
  52.  
  53.  
  54.  
  55. def main():
  56. choice = ""
  57. done = False # loop variable
  58.  
  59. #variables for game
  60. milesTraveled = 0
  61. thirst = 0
  62. camelTiredness = 0
  63. distanceNativesTraveled = -20
  64. drinks = 5
  65.  
  66. # Run the game
  67. while not done:
  68. print(
  69. """
  70. Welcome to the Camel Game?
  71. You have stolen a camel to make your way across the great Mobi desert.
  72. The natives want their camel back and are chasing you down? Survive your
  73. desert trek and out run the native.
  74.  
  75. A - Drink from you canteen.
  76. B - Ahead moderate speed.
  77. C - Ahead full speed.
  78. D - Stop and rest for night.
  79. E - Status check.
  80. Q - Quit the Game
  81. """
  82. )
  83.  
  84. choice = input(" Your choice?\n")
  85. if choice.upper() == "Q":
  86. done = True
  87. quit()
  88.  
  89. # Drink from your canteen
  90. elif choice.upper() == "A":
  91. thirst, drinks = drinkFromCanteen(thirst, drinks)
  92.  
  93. # Move ahead at a moderate speed
  94. elif choice.upper() == "B":
  95. milesTraveled, thirst, camelTiredness, distanceNativesTraveled = moveMod(milesTraveled, thirst, camelTiredness, distanceNativesTraveled)
  96.  
  97. # Move ahead at Full Speed
  98. elif choice.upper() == "C":
  99. milesTraveled, thirst, camelTiredness, distanceNativesTraveled = moveFull(milesTraveled, thirst, camelTiredness, distanceNativesTraveled)
  100.  
  101. # Stop and rest for the night
  102. elif choice.upper() == "D":
  103. camelTiredness, distanceNativesTraveled = stopRest(camelTiredness, distanceNativesTraveled)
  104.  
  105. # Status Check
  106. elif choice.upper() == "E":
  107. status(milesTraveled, distanceNativesTraveled, drinks)
  108.  
  109. # If the user types an incorrect answer
  110. else:
  111. print("That was not a correct choice - Enter (A through E or Q)")
  112.  
  113. # Determine thirst
  114. if not done:
  115. if thirst > 4 and thirst <= 6:
  116. print ("You are thristy.")
  117. elif thirst > 6:
  118. print ("You have died of thrist!")
  119. done = True
  120.  
  121. # Determine camel tiredness
  122. if not done:
  123. if camelTiredness > 5 and camelTiredness <= 8:
  124. print ("Your camel is getting tired!")
  125. elif camelTiredness > 8:
  126. print ("Your camel is dead.")
  127. done = True
  128.  
  129. # Determine distance natives traveled
  130. if distanceNativesTraveled >= 0:
  131. print ("The native caught up! You lose!")
  132. elif distanceNativesTraveled >-15:
  133. print ("The natives are getting close!")
  134.  
  135. # Determine whether you've won the game
  136. if not done:
  137. if milesTraveled >= 200:
  138. print ("You won!")
  139. done = True
  140.  
  141. # Determine whether an oasis was found
  142. if random.randrange (1, 21) == 20:
  143. print ("You have found an oasis.")
  144. drinks = 5
  145. thirst = 0
  146. camelTiredness = 0
  147.  
  148. # call main
  149. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement