import random import time class Player: def __init__(self, name): self.name = name self.health = 100 self.level = 1 def attack(self): return random.randint(10, 20) def take_damage(self, damage): self.health -= damage class Dungeon: def __init__(self, name): self.name = name self.enemies = ["Skeleton", "Zombie", "Goblin"] def explore(self, player): print(f"You are exploring {self.name}...") time.sleep(2) enemy = random.choice(self.enemies) print(f"You've encountered a {enemy}!") while player.health > 0: print("\n1. Attack\n2. Run") choice = input("Choose your action: ") if choice == "1": enemy_health = random.randint(50, 100) enemy_damage = random.randint(10, 20) while enemy_health > 0: player_damage = player.attack() enemy_health -= player_damage print(f"You hit the {enemy} for {player_damage} damage.") if enemy_health <= 0: print(f"You defeated the {enemy}!") break player.take_damage(enemy_damage) print(f"The {enemy} hits you for {enemy_damage} damage. Your health: {player.health}") if player.health <= 0: print("Game Over! You were defeated.") exit() elif choice == "2": print("You managed to escape!") break else: print("Invalid choice. Try again.") def boss_battle(player, boss_name): print(f"Prepare to face {boss_name}!") boss_health = 150 * player.level boss_damage = 25 * player.level while boss_health > 0: player_damage = player.attack() boss_health -= player_damage print(f"You hit {boss_name} for {player_damage} damage.") if boss_health <= 0: print(f"Congratulations! You defeated {boss_name}!") break player.take_damage(boss_damage) print(f"{boss_name} hits you for {boss_damage} damage. Your health: {player.health}") if player.health <= 0: print("Game Over! You were defeated.") exit() def main(): print("Welcome to the Epic Dungeon Crawler Adventure!") player_name = input("Enter your name: ") player = Player(player_name) # Level 1 print("\n--- Level 1: The Dark Forest ---") for i in range(3): # Three dungeons in Level 1 dungeon = Dungeon(f"Dungeon {i+1}") dungeon.explore(player) boss_battle(player, "Lebron James") player.level += 1 print("You have leveled up! Proceed to Level 2.") # Level 2 print("\n--- Level 2: The Haunted Castle ---") for i in range(5): # Five dungeons in Level 2 dungeon = Dungeon(f"Dungeon {i+1}") dungeon.explore(player) boss_battle(player, "James Charles") player.level += 1 print("You have leveled up! Proceed to Level 3.") # Level 3 print("\n--- Level 3: The Volcanic Lair ---") for i in range(7): # Seven dungeons in Level 3 dungeon = Dungeon(f"Dungeon {i+1}") dungeon.explore(player) boss_battle(player, "James Charles") print("Congratulations! You've completed all levels and defeated all bosses!") if __name__ == "__main__": main()