Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.1 kB
1
Indexable
Never
import random

print("""Welcome to 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.""")

miles_traveled = 0
thirst = 0
camel_tiredness = 0
canteen = 5
natives_traveled = -20
natives_behind = miles_traveled - natives_traveled

while True:
    print("""
    A. Drink from your canteen.
    B. Ahead moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check.
    Q. Quit.
    """)
    
    # Get the user input.
    user_choice = input("Pick an option: ")
    user_choice = user_choice.lower()
    
    # Quit.
    if user_choice == 'q':
        break
        
    # Status check.
    elif user_choice == 'e':
        print(f"\nMiles traveled: {miles_traveled}.")
        print(f"Drinks in canteen: {canteen}.")
        print(f"The natives are {natives_behind} miles behind you.")
        
    # Stop for the night.
    elif user_choice == 'd':
        camel_tiredness = 0
        natives_traveled += random.randint(10, 15)
    
    # Full speed.
    elif user_choice == 'c':
        thirst += 1
        camel_tiredness += random.randint(1, 3)
        miles_traveled += random.randint(10, 20)
        natives_traveled += random.randint(10, 15)
        
    # Moderate speed.
    elif user_choice == 'b':
        thirst += 1
        camel_tiredness += 1
        miles_traveled += random.randint(5, 12)
        natives_traveled += random.randint(10, 15)
        
    # Drink from canteen.
    elif user_choice == 'a':
        if canteen != 0:
            thirst = 0
            canteen -= 1
            print(f"You took a sip! There are {canteen} sips left.")
        else:
            print("Your canteen is empty!")
    
    # Check for input.
    else:
        print("Invalid input. Try again.")
        continue
    
    # Position checks.
    if miles_traveled >= 200:
        print("You made it across the desert!")
        break
    elif natives_traveled >= miles_traveled:
        print("The natives caught you! \nIt's a fight to the death!")
        if random.randrange(5) == 0:
            print("In a blood rage you kill all the natives and escape.")
            break
        else:
            print("Alas, the natives were too strong. They beheaded you.")
            break
    
    # Health checks.
    # 1 in 20 chance of finding an oasis.
    if user_choice.lower() != 'd' and random.randrange(20) == 0:
        camel_tiredness, thirst, canteen = 0, 0, 3
        print("You have found an oasis!")
    elif thirst > 6:
        print("You died of dehydration!")
        break
    elif camel_tiredness > 8:
        print("Your camel is dead.")
        break
    
    # Warnings.
    if natives_traveled >= miles_traveled - 15:
        print("The natives are drawing near!")
    if thirst > 4:
        print("You are thirsty")
    if camel_tiredness > 5:
        print("Your camel is getting tired.")
    
    # Let the user know how far they are if not dead.
    print(f"You have traveled {miles_traveled} miles.")