Game for PYTHON

praket_singh_1c341a50266b

praket singh

Posted on June 7, 2024

Game for PYTHON
import random
import time

class Player:
    def __init__(self, name):
        self.name = name
        self.health = 100
        self.gold = 5
        self.berries = 0
        self.attack = 10
        self.defense = 5
        self.potions = 3
        self.weak_spell = 1
        self.special_ability = None
        self.stamina = 120
        self.active_quest = None
        self.job = None
        self.salary = 0
        self.required_attributes = {}
        self.has_attempted_run = False
        self.upgrade_points = 0
        self.attacks = {
            "Roundhouse kick": {"damage": 10, "stamina_cost": 10},
            "Heavy Strike": {"damage": 20, "stamina_cost": 25},
            "Power Shot": {"damage": 30, "stamina_cost": 35}
        }

    def change_job(self, company):
        if all(getattr(self, attr, 0) >= req for attr, req in company.required_attributes.items()):
            self.gold += company.salary
            self.job = company.name
            print(
                f"Congratulations! You have been hired by {company.name} and received a salary of {company.salary} gold!")
        else:
            print("You do not meet the requirements to join this company.")

    def undertake_quest(self, quest):
        self.active_quest = quest
        print(f"You undertook the quest: {quest.name}")

    def display_companies(companies):
        print("Available Companies:")
        for idx, company in enumerate(companies, start=1):
            print(
                f"{idx}. {company.name} - Salary: {company.salary}, Required Attributes: {company.required_attributes}")

    def complete_quest(self):
        if self.active_quest and not self.active_quest.completed:
            self.gold += self.active_quest.reward_gold
            self.upgrade_points += self.active_quest.reward_upgrade_points
            self.active_quest.completed = True
            print(f"Congratulations! You completed the quest: {self.active_quest.name}")
            print(
                f"You received {self.active_quest.reward_gold} gold and {self.active_quest.reward_upgrade_points} upgrade points!")
            self.active_quest = None
        else:
            print("No active quest to complete.")

    def display_details(self):
        print(f"Quest: {self.name}")
        print(f"Description: {self.description}")
        print(f"Reward: {self.reward_gold} gold, {self.reward_upgrade_points} upgrade points")
        print("Status: Completed" if self.completed else "Status: In Progress")

    def reset_run_attempt(self):
        self.has_attempted_run = False

    def attempt_run(self):
        if not self.has_attempted_run:
            self.has_attempted_run = True
            return True
        else:
            print("You have already attempted to run during this battle.")
            self.has_attempted_run = False

    def display_stats(self):
        print(f"Player: {self.name}")
        print(f"Health: {self.health}")
        print(f"Gold: {self.gold}")
        print(f"Berries: {self.berries}")
        print(f"Attack: {self.attack}")
        print(f"Defense: {self.defense}")
        print(f"Potions: {self.potions}")
        print(f"Stamina: {self.stamina}")
        print(f"Upgrade Points: {self.upgrade_points}")
        if self.special_ability:
            print(f"Special Ability: {self.special_ability.name}")
        print("\nAttacks:")
        for attack, details in self.attacks.items():
            if details.get("unlocked", True):
                print("Roundhouse kick: damage-10, stamina cost-10")
                print("Heavy strike: damage-20, stamina cost-25")
                print("Power shot: damage-30, stamina cost-35")

    def attack_enemy(self, enemy, attack_name):
        damage = 0
        if attack_name in self.attacks:
            if self.stamina >= self.attacks[attack_name]["stamina_cost"]:
                damage = self.attacks[attack_name]["damage"]
                if self.special_ability:
                    damage += self.special_ability.activate()
                enemy.take_damage(max(0, damage - enemy.defense))
                print(f"You use {attack_name} and deal {max(0, damage - enemy.defense)} damage to the {enemy.name}!")
                self.stamina -= self.attacks[attack_name]["stamina_cost"]
            else:
                print("Not enough stamina to perform this attack!")
        else:
            print("Invalid attack choice. Please try again.")

    def simple_attack(self, enemy):
        damage = max(0, self.attack - enemy.defense)
        enemy.health -= damage
        print(f"You attack the enemy and deal {damage} damage!")

    def take_damage(self, damage):
        self.health -= damage

    def use_potion(self):
        if self.potions > 0:
            self.health += 20
            self.potions -= 1
            print("You use a potion and restore 20 health.")
        else:
            print("You don't have any potions left!")

class Enemy:
    def __init__(self, name, health, attack, defense, gold_drop, is_god=False, key_fragment_drop=False):
        self.name = name
        self.health = health
        self.attack = attack
        self.defense = defense
        self.gold_drop = gold_drop
        self.is_god = is_god
        self.key_fragment_drop = key_fragment_drop

    def drop_items(self, player):
        if self.key_fragment_drop:
            player.defeat_enemy()

    def drop_fruit(self):
        if self.is_god:
            return random.choice(["Gomu Gomu no Mi", "Hie Hie no Mi", "Mera Mera no Mi"])
        else:
            return None

    def attack_player(self, player):
        damage = max(0, self.attack - player.defense)
        player.take_damage(damage)
        print(f"The {self.name} attacks you and deals {damage} damage!")

    def take_damage(self, damage):
        self.health -= damage

class BossEnemy(Enemy):
    def __init__(self, name, health, attack, defense, gold_drop, is_god=False):
        super().__init__(name, health, attack, defense, gold_drop, is_god)

    def boss_battle(player, friend, boss_enemy):
        print(f"A formidable foe, {boss_enemy.name}, appears!")
        while player.health > 0 and boss_enemy.health > 0:
            print("\nPlayer's Turn:")
            player.display_stats()
            print(f"{boss_enemy.name}'s Health: {boss_enemy.health}")
            print("1. Basic punch")
            print("Attacks:")
            for idx, attack_name in enumerate(player.attacks.keys(), start=2):
                print(f"{idx}. {attack_name}")
            print("5. Use Potion")
            print("6. Run")
            if player.special_ability:
                print("7. Use Special Ability")
            choice = input("Enter your choice number: ")

            if choice.isdigit() and 1 <= int(choice) <= 6:
                choice = int(choice)
                if choice == 1:
                    player.simple_attack(enemy)
                elif choice == 2:
                    attack_name = "Roundhouse kick"
                elif choice == 3:
                    attack_name = "Heavy Strike"
                elif choice == 4:
                    attack_name = "Power Shot"
                elif choice == 5 :
                    player.use_potion()
                elif choice == 6:
                    print("You attempt to run away!")
                    if random.random() < 0.55:
                        print("You successfully escaped from the battle!")
                        player.reset_run_attempt()
                        return True
                    else:
                        print("You couldn't escape!")
                        print(f"{enemy.name}'s Turn:")
                        enemy.attack_player(player)
                        continue
                elif choice == 7 and player.special_ability:
                    attack_name = "Special Ability"
                else:
                    print("Invalid choice. Please try again.")
                    continue

                player.attack_enemy(enemy, attack_name)

                if boss_enemy.health <= 0:
                    print(f"Congratulations! You defeated {boss_enemy.name}!")
                    print(f"You received {boss_enemy.gold_drop} gold!")
                    break

                print(f"\n{boss_enemy.name}'s Turn:")
                boss_enemy.attack_player(player)

                if player.health <= 0:
                    print("You have been defeated! Game over.")
                    break

class SpecialAbility:
    def __init__(self, name, description, damage, cooldown):
        self.name = name
        self.description = description
        self.damage = damage
        self.cooldown = cooldown
        self.last_used_time = 0

    def activate(self):
        current_time = time.time()
        if current_time - self.last_used_time >= self.cooldown:
            print(f"You activate {self.name}: {self.description}")
            self.last_used_time = current_time
            return self.damage
        else:
            print(f"The ability {self.name} is still on cooldown!")
            return 0

class quest:
    def undertake_quest(self, quest):
        if self.active_quest:
            print("You are already on a quest. Complete it before taking another.")

class Quest:
    def __init__(self, name, description, reward_gold, reward_upgrade_points):
        self.name = name
        self.description = description
        self.reward_gold = reward_gold
        self.reward_upgrade_points = reward_upgrade_points
        self.completed = False

    def undertake_quest(self, quest):
        self.active_quest = quest
        print(f"You undertook the quest: {quest.name}")

    def complete_quest(self):
        if self.active_quest and not self.active_quest.completed:
            self.gold += self.active_quest.reward_gold
            self.upgrade_points += self.active_quest.reward_upgrade_points
            self.active_quest.completed = True
            print(f"Congratulations! You completed the quest: {self.active_quest.name}")
            print(
                f"You received {self.active_quest.reward_gold} gold and {self.active_quest.reward_upgrade_points} upgrade points!")
            self.active_quest = None
        else:
            print("No active quest to complete.")

    def display_details(self):
        print(f"Quest: {self.name}")
        print(f"Description: {self.description}")
        print(f"Reward: {self.reward_gold} gold, {self.reward_upgrade_points} upgrade points")
        print("Status: Completed" if self.completed else "Status: In Progress")

class BossKeyQuest:
    def __init__(self):
        self.key_fragments_needed = 3
        self.key_fragments_collected = 0

    def start_quest(self):
        print("You've received a quest to obtain the boss key!")
        print("Defeat enemies to collect their key fragments.")
        print(f"You need to collect {self.key_fragments_needed} key fragments to unlock the boss chamber.")

    def check_progress(self):
        print(f"You have collected {self.key_fragments_collected} out of {self.key_fragments_needed} key fragments.")

    def collect_key_fragment(self):
        self.key_fragments_collected += 1
        print("You collected a key fragment!")

    def complete_quest(self):
        if self.key_fragments_collected >= self.key_fragments_needed:
            print("Congratulations! You have collected all key fragments and unlocked the boss chamber.")
            return True
        else:
            print("You still need to collect more key fragments to unlock the boss chamber.")
            return False

class Company:
    def __init__(self, name, salary, required_attributes):
        self.name = name
        self.salary = salary
        self.required_attributes = required_attributes


class NPC:
    def __init__(self, name, dialogue):
        self.name = name
        self.dialogue = dialogue

    def interact(self):
        print(f"{self.name}: {self.dialogue}")

class Shop:
    def __init__(self):
        self.items = {
            "Health Potion": {"price": 20, "effect": "restore health"},
            "Old set of armor and sword": {"price": 40, "effect": "increse attack and defense by 2" },
            "Sword": {"price": 50, "effect": "increase attack by 4"},
            "Armor": {"price": 50, "effect": "increase defense by 4"},
            "Elixir of Life": {"price": 100, "effect": "health buff of 50 instantly"},
            "Aluminum Sword": {"price": 57, "effect": "increase attack by 5"},
            "Chainmail Armor": {"price": 57, "effect": "increase defense by 5"},
            "Iron Sword": {"price": 65, "effect": "increase attack by 10"},
            "Iron Armor": {"price": 65, "effect": "increase defense by 10"},
            "Gold Sword": {"price": 80, "effect": "increase attack by 15"},
            "Gold Armor": {"price": 80, "effect": "increase defense by 15"},
            "Wizard's Staff": {"price": 100, "effect": "increase attack by 20"},
            "Heavenly Knight's Armor": {"price": 110, "effect": "increase defense by 25"},
            "Ring of Vigor": {"price": 60, "effect": "increase stamina by 20"}
        }
        self.mythical_items = {
            "Conqueror's Sword": {"price": 20, "effect": "massive increase in attack"},
            "Dragon Armor": {"price": 20, "effect": "massive increase in defense"},
            "Eternal Life": {"price": 21, "effect": "massive increase in health"},
            "Ring of valor": {"price": 25, "effect": "increase in stamina, health"},
            "The eternal dagger": {"price": 29, "effect":"increase in attack by 29" }
        }
        self.special_abilities = {
            "Gomu Gomu no Mi": SpecialAbility("Gomu Gomu no Mi", "stretching ability", 15, 60),
            "Hie Hie no Mi": SpecialAbility("Hie Hie no Mi", "ice manipulation", 20, 90),
            "Mera Mera no Mi": SpecialAbility("Mera Mera no Mi", "fire manipulation", 25, 120)
        }
        self.exchange_rate = 10

    def display_items(self):
        print("Welcome to the shop! Here are the available items:")
        print("Regular Items(gold):")
        for item, stats in self.items.items():
            print(f"{item}: Price: {stats['price']} Gold, Effect: {stats['effect']}")
        print("\nMythical Items(berries):")
        for item, stats in self.mythical_items.items():
            print(f"{item}: Price: {stats['price']} Berries, Effect: {stats['effect']}")
        print("\nSpecial Abilities(can't be bought):")
        for ability, stats in self.special_abilities.items():
            print(f"{ability}: Description: {stats.description}, Damage: {stats.damage}, Cooldown: {stats.cooldown} seconds")

    def buy_item(self, player, item_name):
        if item_name in self.items:
            item_price = self.items[item_name]["price"]
            if player.gold >= item_price:
                if item_name == "Health Potion":
                    player.potions += 1
                elif item_name == "Old set of armor and sword":
                    player.attack += 2
                    player.defense += 2
                elif item_name == "Sword":
                    player.attack += 4
                elif item_name == "Armor":
                    player.defense += 4
                elif item_name == "Elixir of Life":
                    player.health += 50
                elif item_name == "Aluminum Sword":
                    player.attack += 5
                elif item_name == "chainmail armor":
                    player.defense += 5
                elif item_name == "Iron Sword":
                    player.attack += 10
                elif item_name == "Iron Armor":
                    player.defense += 10
                elif item_name == "Gold Sword":
                    player.attack += 15
                elif item_name == "Gold armor":
                    player.defense += 15
                elif item_name == "wizard's staff":
                    player.attack += 20
                elif item_name == "Heavenly knight's armor":
                    player.defense += 25
                elif item_name == "Ring of Vigor":
                    player.stamina += 20
                player.gold -= item_price
                print(f"You bought {item_name} for {item_price} gold!")
            else:
                print("You don't have enough gold to buy this item!")
        elif item_name in self.mythical_items:
            item_price = self.mythical_items[item_name]["price"]
            if player.berries >= item_price:
                if item_name == "Conqueror's Sword":
                    player.attack += 27
                elif item_name == "Dragon Armor":
                    player.defense += 29
                elif item_name == "Eternal Life":
                    player.health += 75
                elif item_name == "Ring of valor":
                    player.stamina += 50
                    player.health += 25
                elif item_name == "The eternal dagger":
                    player.attack += 29
                player.berries -= item_price
                print(f"You bought {item_name} for {item_price} berries!")
            else:
                print("You don't have enough berries to buy this item!")
        else:
            print("Item not available in the shop!")

class Friend:
    def __init__(self, name):
        self.name = name
        self.health = 100
        self.attack = 15
        self.defense = 8
        self.upgrade_points_cost = 5  # Define cost of upgrading friend
        self.upgrade_level = 0

    def display_stats(self):
        print(f"{self.name}'s Stats:")
        print(f"Health: {self.health}")
        print(f"Attack: {self.attack}")
        print(f"Defense: {self.defense}")
        print(f"Upgrade Level: {self.upgrade_level}")

    def upgrade(self, player):
        if player.upgrade_points >= self.upgrade_points_cost:
            player.upgrade_points -= self.upgrade_points_cost
            self.attack += 5  # Example upgrade: Increase attack by 5
            self.defense += 3  # Example upgrade: Increase defense by 2
            self.health += 10  # Example upgrade: Increase health by 10
            self.upgrade_level += 1
            print(f"{self.name} has been upgraded!")
        else:
            print("Insufficient upgrade points.")

def battle(player, friend, enemy, enemies):
    print(f"A wild {enemy.name} appears!")
    print(f"{player.name}'s stats:")
    player.display_stats()
    print(f"{friend.name}'s stats:")
    friend.display_stats()

    num_enemies = random.randint(1, 2)

    if num_enemies == 2 :
        enemy.health *= 1.4
    total_gold_drop = enemy.gold_drop * num_enemies
    enemy.attack *= num_enemies
    enemy.defense *= num_enemies


    print(f"{enemy.name}'s stats:")
    print(f"Health: {enemy.health}")
    print(f"Attack: {enemy.attack}")
    print(f"Defense: {enemy.defense}")

    while player.health > 0 and enemy.health > 0:
        print("\nPlayer's Turn:")
        print("1. Basic punch")
        print("Attacks:")
        for idx, attack_name in enumerate(player.attacks.keys(), start=2):
            print(f"{idx}. {attack_name}")
        print("Others:")
        print("5. Use Potion")
        print("6. Run")
        if player.special_ability:
            print("7. Use Special Ability")
        choice = input("Enter your choice number: ")

        if choice.isdigit() and 1 <= int(choice) <= 7:
            choice = int(choice)
            if choice == 1:
                player.simple_attack(enemy)
            elif choice in range(2, 5):
                attack_name = list(player.attacks.keys())[choice - 2]
                player.attack_enemy(enemy, attack_name)
            elif choice == 5:
                player.use_potion()
            elif choice == 6:
                print("You attempt to run away!")
                if random.random() < 0.4991:
                    print("You successfully escaped from the battle!")
                    return False  # Return False when player escapes
                else:
                    print("You couldn't escape!")
                    player.attempt_run()
                    print(f"{enemy.name}'s Turn:")
                    enemy.attack_player(player)
                    continue
            elif choice == 7 and player.special_ability:
                player.attack_enemy(enemy, "Special Ability")
            else:
                print("Invalid choice. Please try again.")
                continue

            if enemy.health <= 0:
                print(f"You defeated the {enemy.name}!")
                player.gold += enemy.gold_drop
                print(f"You received {enemy.gold_drop} gold!")
                fruit = enemy.drop_fruit()
                if fruit:
                    print(f"The {enemy.name} dropped a {fruit}!")
                    if fruit in player.special_abilities:
                        print("You feel a strange power emanating from the fruit!")
                        print(f"It seems you acquired the ability: {fruit}")
                        player.special_ability = player.special_abilities[fruit]
                return True

            print(f"{enemy.name}'s Turn:")
            enemy.attack_player(player)
            print(f"{player.name}'s stats:")
            player.display_stats()
            print(f"{friend.name}'s stats:")
            friend.display_stats()
            print(f"{enemy.name}'s stats:")
            print(f"Health: {enemy.health}")
            print(f"Attack: {enemy.attack}")
            print(f"Defense: {enemy.defense}")
        else:
            print("Invalid choice. Please enter a number between 1 and 7.")

    if player.health <= 0:
        print("You have been defeated! Game over.")
        return False
    return True

def dungeon(player, friend, dungeon_enemies):
    print("Welcome to the dungeon!")
    print("You are not alone here. Your friend is with you.")

    while player.health > 0:
        if len(dungeon_enemies) == 0:
            print("Congratulations! You defeated all enemies in the dungeon!")
            break

        print("\nCurrent enemies in the dungeon:")
        for idx, enemy in enumerate(dungeon_enemies):
            print(f"{idx + 1}. {enemy.name}")

        print("\nWhat would you like to do?")
        print("1. Battle an enemy")
        print("2. Shop")
        print("3. quest")
        print("4. upgrade friend")
        print("5. Quit")
        choice = input("Enter your choice number: ")

        if choice == "1":
            enemy_choice = random.choice(dungeon_enemies)
            if battle(player, friend, enemy_choice):
                dungeon_enemies.remove(enemy_choice)
        elif choice == "2":
            shop.display_items()
            item_choice = input("Enter the item you want to buy or 'exit' to leave the shop: ")
            if item_choice.lower() != 'exit':
                shop.buy_item(player, item_choice)
        elif choice == "3":
            print("Available Quests:")
            for idx, quest in enumerate(quests, start=1):
                quest.display_details()
            quest_choice = input("Enter the number of the quest you want to undertake or 'exit' to go back: ")
            if quest_choice.isdigit() and 1 <= int(quest_choice) <= len(quests):
                player.undertake_quest(quests[int(quest_choice) - 1]) if hasattr(player, 'undertake_quest') else print(
                    "Player cannot undertake quests.")
            elif quest_choice.lower() == 'exit':
                continue
            else:
                print("Invalid quest choice. Please try again.")
        elif choice == "4":
            friend.upgrade(player)
        elif choice == "5":
            print("Exiting the dungeon...")
            break
        else:
            print("Invalid choice. Please try again.")

def main():
    player_name = input("Enter your name: ")
    player = Player(player_name)
    friend = Friend("Ally")
    shop = Shop()
    enemies = [
        Enemy("Demon", 50, 8, 2, 20, False, False),
        Enemy("Orc", 70, 12, 5, 30),
        Enemy("Dragon", 100, 20, 10, 50),
        Enemy("Giants", 80, 17, 9, 40),
        Enemy("Undead Insects", 61, 10, 3, 25),
        Enemy("Blood hyena", 75, 16, 7, 42),
        Enemy("Sea Kings", 90, 21, 9, 55, False, True),
        Enemy("Sea Kings (Enraged)", 110, 25, 13, 63),
        Enemy("Sea Beast", 120, 30, 15, 70),
        Enemy("Jin-Woo (HUMAN, HUNTER)", 125, 35, 20, 75, False, True),
        Enemy("Cerberus", 132, 40, 25, 86),
        Enemy("GOD", 140, 45, 25, 100, True),
        Enemy("GOD (Enraged)", 155, 50, 30, 110, True,True)
              ]

    dark_lord = BossEnemy("Dark Lord", 200, 45, 26, 181)

    dungeon_enemies = [
        Enemy("Skeleton", 60, 10, 10, 40),
        Enemy("Goblin", 100, 24, 16, 60),
        Enemy("Witch", 115, 42, 24, 110),
        Enemy("warewolfs", 140, 60, 37, 140),
        Enemy("Dark Knight", 145, 80, 50, 172),
        Enemy("Demon Lord", 150, 90, 55, 200, True),
        Enemy("Ancient Dragon", 200, 100, 60, 220)
    ]

    quests = [
        Quest("Defeat the Sea beeast", "Defeat the notorious Sea beast .", 50, 1),
        Quest("defeat the GOD", "Defeat the rebel GOD.", 100, 2),
        Quest("defeat demon lord", "defeat the demon lord and free the captured spirits .", 150, 3)
    ]

    npc_1 = NPC("Villager", "Thank you for helping our village. We are forever grateful.")
    npc_2 = NPC("Blacksmith","Looking for some new gear? I have the finest weapons and armor in the land. Just visit the shop")

    companies = [
        Company("new hunter guild", 45, {"attack": 10, "defense": 5}),
        Company("Hunter Association", 100, {"attack": 50, "defense": 30}),
        Company("Magic Guild", 120, {"attack": 40, "stamina": 20, "defense": 50}),
        Company("Mercenaries Guild", 80, {"attack": 60, "stamina": 70}),
        Company("Explorers Guild", 90, {"defense": 40, "stamina": 60}),
    ]

    boss_quest = BossKeyQuest()
    boss_quest.start_quest()

    print("Welcome to the RPG game!")
    print("Your grandpa just passed away and you inheritd 5 gold")
    print("new hunter guild offerd you a contract sign it in companies")
    print("You have been hired by a hunter organization.")
    print("Your goal is to defeat all enemies and become the ultimate warrior.")
    print("1 berry = 10 gold")
    print("Fruits can only be dropped by GOD.")
    print("A random number of enemies from one to two can spawn")

    while player.health > 0:
        if len(enemies) == 0:
            print("Congratulations! You defeated all enemies and opened a portal to a dungeon!")
            print("You enter the portal and find yourself in a dark dungeon...")
            print("But don't worry, you have a friend to help you in this journey!")
            dungeon(player, friend, dungeon_enemies)
            friend.upgrade(player)  # Upgrade friend when entering the dungeon
            break

        print("\nCurrent enemies:")
        for idx, enemy in enumerate(enemies):
            print(f"{idx + 1}. {enemy.name}")

        print("\nWhat would you like to do?")
        print("1. Battle an enemy")
        print("2. Visit the shop")
        print("3. Upgrade friend")
        print("4. Stats")
        print("5. View quest")
        print("6. Interact with NPC")
        print("7. JOB(companies)")
        print("8. special quest")
        print("9. Credits")
        print("10. Quit")
        choice = input("Enter your choice number: ")

        if choice == "1":
            if enemies:  # Check if there are remaining enemies
                enemy_choice = random.choice(enemies)
                if battle(player, friend, enemy_choice, enemies):
                    enemies.remove(enemy_choice)
        elif choice == "2":
            shop.display_items()
            item_choice = input("Enter the item you want to buy or 'exit' to leave the shop: ")
            if item_choice.lower() != 'exit':
                shop.buy_item(player, item_choice)
        elif choice == "3":
            friend.upgrade(player)
        elif choice == "4":
            player.display_stats()
            friend.display_stats()
        elif choice == "6":
            print("NPCs available for interaction:")
            print("1. Villager")
            print("2. Blacksmith")
            npc_choice = input("Enter the number of the NPC you want to interact with: ")
            if npc_choice == "1":
                npc_1.interact()
            elif npc_choice == "2":
                npc_2.interact()
            else:
                print("Invalid NPC choice.")
        elif choice == "5":
            if player.active_quest:
                print("You are already on a quest. Complete it before taking another.")
            else:
                print("Available Quests:")
                for idx, quest in enumerate(quests, start=1):
                    quest.display_details()
                quest_choice = input("Enter the number of the quest you want to undertake or 'exit' to go back: ")
                if quest_choice.isdigit() and 1 <= int(quest_choice) <= len(quests):
                    player.undertake_quest(quests[int(quest_choice) - 1])
                elif quest_choice.lower() == 'exit':
                    continue
                else:
                    print("Invalid quest choice. Please try again.")
        elif choice == "7":
            print("Available Companies:")
            for idx, company in enumerate(companies, start=1):
                print(f"{idx}. {company.name} - Salary: {company.salary} gold, Required Attributes: {company.required_attributes}")
            company_choice = input("Enter the number of the company you want to apply to or 'exit' to go back: ")
            if company_choice.isdigit() and 1 <= int(company_choice) <= len(companies):
                player.change_job(companies[int(company_choice) - 1])
            elif company_choice.lower() == 'exit':
                continue
            else:
                print("Invalid company choice. Please try again.")
        elif choice == "8":
            boss_quest.check_progress()
            op = input("type EXIT to go back to home- ")
            if op == 'EXIT':
                continue
        elif choice == "9":
            print("Game by - Praket singh bhadauria")
            print("inspiration - Solo leveling, One piece")
            op = input("type EXIT to go back to home- ")
            if op == 'EXIT':
                continue
        elif choice == "10":
            print("Thanks for playing!")
            break
        else:
            print("Invalid choice. Please try again.")

            if boss_quest.complete_quest():
                # Generate the boss enemy and start the boss battle
                boss_enemy = BossEnemy("Dark Lord", 300, 50, 30, 1000)
                BossEnemy.boss_battle(player, friend, boss_enemy)
                break

if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
praket_singh_1c341a50266b
praket singh

Posted on June 7, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related