Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def quit():
- print("You have quit the game.")
- # status
- def status(milesTraveled, distanceNativesTraveled, drinks):
- print ("Miles traveled:", milesTraveled)
- print ("Drinks in canteen:", drinks)
- print ("The natives are", abs(distanceNativesTraveled), "miles behind you.")
- # Drink from Canteen
- def drinkFromCanteen(thirst, drinks):
- if drinks > 0:
- print("You drink from your canteen.")
- drinks -= 1
- thirst = 0
- else:
- print ("Your canteen is empty.")
- return thirst, drinks
- # Move ahead at a moderate speed
- def moveMod(milesTraveled, thirst, camelTiredness, distanceNativesTraveled):
- print("You move forward at an easy pace.")
- user_dist = random.randrange(5, 13)
- milesTraveled += user_dist
- thirst += 1
- camelTiredness += 1
- distanceNativesTraveled += random.randrange(7, 15)
- distanceNativesTraveled -= user_dist
- print ("You have traveled", milesTraveled, "miles.")
- return milesTraveled, thirst, camelTiredness, distanceNativesTraveled
- # Move ahead at Full Speed
- def moveFull(milesTraveled, thirst, camelTiredness, distanceNativesTraveled):
- print("You rush forward trying to escape the angry natives!")
- user_dist = random.randrange(10, 21)
- milesTraveled += user_dist
- thirst += 1
- camelTiredness += random.randrange(1, 4)
- distanceNativesTraveled += random.randrange(7, 15)
- distanceNativesTraveled -= user_dist
- print ("You have traveled", milesTraveled, "miles.")
- return milesTraveled, thirst, camelTiredness, distanceNativesTraveled
- # Stop and rest for the night
- def stopRest(camelTiredness, distanceNativesTraveled):
- camelTiredness = 0
- print ("The camel is happy.")
- distanceNativesTraveled += random.randrange(7, 15)
- return camelTiredness, distanceNativesTraveled
- def main():
- choice = ""
- done = False # loop variable
- #variables for game
- milesTraveled = 0
- thirst = 0
- camelTiredness = 0
- distanceNativesTraveled = -20
- drinks = 5
- # Run the game
- while not done:
- print(
- """
- Welcome to the Camel Game?
- 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 out run the native.
- A - Drink from you canteen.
- B - Ahead moderate speed.
- C - Ahead full speed.
- D - Stop and rest for night.
- E - Status check.
- Q - Quit the Game
- """
- )
- choice = input(" Your choice?\n")
- if choice.upper() == "Q":
- done = True
- quit()
- # Drink from your canteen
- elif choice.upper() == "A":
- thirst, drinks = drinkFromCanteen(thirst, drinks)
- # Move ahead at a moderate speed
- elif choice.upper() == "B":
- milesTraveled, thirst, camelTiredness, distanceNativesTraveled = moveMod(milesTraveled, thirst, camelTiredness, distanceNativesTraveled)
- # Move ahead at Full Speed
- elif choice.upper() == "C":
- milesTraveled, thirst, camelTiredness, distanceNativesTraveled = moveFull(milesTraveled, thirst, camelTiredness, distanceNativesTraveled)
- # Stop and rest for the night
- elif choice.upper() == "D":
- camelTiredness, distanceNativesTraveled = stopRest(camelTiredness, distanceNativesTraveled)
- # Status Check
- elif choice.upper() == "E":
- status(milesTraveled, distanceNativesTraveled, drinks)
- # If the user types an incorrect answer
- else:
- print("That was not a correct choice - Enter (A through E or Q)")
- # Determine thirst
- if not done:
- if thirst > 4 and thirst <= 6:
- print ("You are thristy.")
- elif thirst > 6:
- print ("You have died of thrist!")
- done = True
- # Determine camel tiredness
- if not done:
- if camelTiredness > 5 and camelTiredness <= 8:
- print ("Your camel is getting tired!")
- elif camelTiredness > 8:
- print ("Your camel is dead.")
- done = True
- # Determine distance natives traveled
- if distanceNativesTraveled >= 0:
- print ("The native caught up! You lose!")
- elif distanceNativesTraveled >-15:
- print ("The natives are getting close!")
- # Determine whether you've won the game
- if not done:
- if milesTraveled >= 200:
- print ("You won!")
- done = True
- # Determine whether an oasis was found
- if random.randrange (1, 21) == 20:
- print ("You have found an oasis.")
- drinks = 5
- thirst = 0
- camelTiredness = 0
- # call main
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement