Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import random

class Player:
def __init__(self, name, health):
self.name = name
self.health = health

def use_random_potion(self):
potion = random.choice(["Healing Potion", "Poison Potion"])
if potion == "Healing Potion":
health_recovered = random.randint(10, 20)
self.health += health_recovered
print(f"{self.name} used a Healing Potion and recovered
{health_recovered} health.")
elif potion == "Poison Potion":
damage_taken = random.randint(5, 15)
self.health -= damage_taken
print(f"{self.name} used a Poison Potion and took {damage_taken}
damage.")

def main():
player_name = input("Enter your character's name: ")
player = Player(player_name, 100)

print("Welcome to the Potion Roulette game!")

while True:
print(f"\n{player.name}'s Health: {player.health}")

choice = input("\nChoose an action:\n1. Take a chance (use a random


potion)\n2. Quit\n> ")

if choice == "1":
player.use_random_potion()
if player.health <= 0:
print("Game over! You've lost all your health.")
break
elif choice == "2":
print("Exiting the game.")
break
else:
print("Invalid choice. Please try again.")

if __name__ == "__main__":
main()

You might also like