Update 1.4

PHOTO EMBED

Sun Mar 24 2024 01:58:59 GMT+0000 (Coordinated Universal Time)

Saved by @SkyFragment

import os
import time
import sys

class Player:
    def __init__(self, name, difficulty):
        self.name = name
        self.difficulty = difficulty
        Attack = 0
        Defense = 0
        Dodge = 0
        Speed = 0
        self.gold = 10000
        self.diamonds = 0
        self.experience = 0
        self.level = 1
        self.exp_required = 100
        self.exp_multiplier = 0.75  # 75% increase for experience requirement per level
        self.inventory = {  # Initialize inventory
            "Weapons": [],
            "Armors": [],
            "Shields": [],
            "Footwear": [],
            "Usable Items": []  # Add Usable Items category
        }
        self.equipped_items = {  # Initialize equipped items
            "Weapons": {"name": "Broken Sword", "description": "+10 Damage", "Attack": 10},
            "Armors": {"name": "Broken Armor", "description": "+5 Defense", "Defense": 5},
            "Shields": {"name": "Broken Shield", "description": "+2 Dodge", "Dodge": 2},
            "Footwear": {"name": "Broken Footwear", "description": "+3 Speed", "Speed": 3},
            "Accessories": None,
            "Bag": None
        }
        self.base_stats = {
            "HP": 100,
            "Defense": 0,
            "Attack": 0,
            "Dodge": 0,
            "Speed": 0
        }
        self.max_inventory_slots = 30
        self.update_stats()  # Update player stats based on equipped items
        
    def visit_inventory(self):
        while True:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Inventory:")
            print("=" * 40)
            print("1. Weapons")
            print("2. Armors")
            print("3. Shields")
            print("4. Footwear")
            print("5. Usable Items")
            print("6. Back to Player Status")
            print("\nEnter the number to select an option.")

            choice = input("")

            if choice == "1":
                self.display_items("Weapons")
            elif choice == "2":
                self.display_items("Armors")
            elif choice == "3":
                self.display_items("Shields")
            elif choice == "4":
                self.display_items("Footwear")
            elif choice == "5":
                self.display_items("Usable Items")
            elif choice == "6":
                self.display_status()
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(1)

    def display_items(self, item_type):
        while True:
            os.system('cls' if os.name == 'nt' else 'clear')
            print(f"{item_type}:")
            print("=" * 40)
            if self.inventory[item_type]:
                for idx, item in enumerate(self.inventory[item_type], 1):
                    print(f"{idx}. {item['name']}: {item['description']}")
                print("0. Back to Inventory Menu")
                print("Enter the number to equip the item or 0 to go back.")
                choice = input("")
                if choice == "0":
                    break  # Break out of the inner loop to return to the previous menu
                elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]):
                    self.equip_item(item_type, int(choice) - 1)
                else:
                    print("Invalid option. Please enter a valid number.")
                    time.sleep(1)
            else:
                print("No items in this category.")
                print("Press < to go back")
                choice = input("")
                if choice == "<":
                    break  # Break out of the inner loop to return to the previous menu

    def equip_item(self, item_type, index):
        item = self.inventory[item_type].pop(index)
        if item_type in ["Weapons", "Armors", "Shields", "Footwear"]:
            self.remove_equipped_item(item_type)  # Remove any previously equipped item of the same type
            self.equipped_items[item_type] = item  # Equip the new item
            self.update_stats()  # Update player stats with the new equipment
            print(f"{item['name']} equipped.")
            time.sleep(1)
        else:
            # Handle equipping usable items
            pass
        self.visit_inventory()

    def remove_equipped_item(self, item_type):
        if item_type in self.equipped_items:
            item = self.equipped_items.pop(item_type)
            self.inventory[item_type].append(item)

    def update_stats(self):
        # Reset stats to base values
        for stat in self.base_stats:
            setattr(self, stat.lower(), self.base_stats[stat])

        # Apply bonuses from equipped items
        equipped = False  # Flag to track if any item is equipped
        for item_type, item in self.equipped_items.items():
            if item:
                equipped = True
                self.when_equipped(item)

        # If no items are equipped, set all stats (except HP) to 0
        if not equipped:
            for stat in self.base_stats:
                if stat != "HP":
                    setattr(self, stat.lower(), 0)

    def when_equipped(self, item):
        for stat in item:
            if stat in self.base_stats:
                setattr(self, stat.lower(), self.base_stats[stat] + item[stat])

                
    def display_equipped_items(self):
        os.system('cls' if os.name == 'nt' else 'clear')
        print("Equipped Items:")
        print("=" * 40)
        for item_type, item in self.equipped_items.items():
            if item:
                print(f"{item_type}: {item['name']} - {item['description']}")
            else:
                print(f"{item_type}: None")
                
    def display_status(self):
        clear_screen()
        print("Player Status:")
        print("=" * 40)
        print(f"Name: {self.name}")
        print(f"Difficulty: {self.difficulty}")
        print("-" * 40)
        print("Stats:")
        print(f"HP      :❤️{self.base_stats['HP']}")
        print(f"Defense :🛡️{self.defense}")
        print(f"Attack  :⚔️{self.attack}")
        print(f"Dodge   :🤺{self.dodge}")
        print(f"Speed   :🏃{self.speed}")
        print("-"*40)
        print(f"Level: {self.level}")
        print(f"Experience: {self.experience}/{self.exp_required}")
        print("-"*40)
        print(f"Gold: {self.gold} 💰")
        print(f"Diamonds: {self.diamonds} 💎")
        print("="*40)
        print("Game Options:")
        print("1. Visit Shop")
        print("2. Inventory")
        print("3. Equipped Items")
        print("4. Play Game")
        print("5. Delete this Character")
        print("6. Add 50 Experience Points")
        print("\nEnter the number to select an option.")

        choice = input("")
        if choice == "1":
            self.visit_shop()
        elif choice == "2":
            self.visit_inventory()
        elif choice == "3":
            self.display_equipped_items()
        elif choice == "4":
            self.play_game()
        elif choice == "5":
            return
        elif choice == "6":
            self.add_experience(50)
        else:
            print("Invalid option. Please enter a valid number.")
            time.sleep(1)
            self.display_status()
            
    def calculate_stat(self, stat_name):
        base_stat = getattr(self, stat_name)
        bonus_stat = sum(item.get(stat_name, 0) for item in self.equipped_items.values() if item)
        return base_stat + bonus_stat

    def display_items(self, item_type):
        os.system('cls' if os.name == 'nt' else 'clear')
        print(f"{item_type}:")
        print("=" * 40)
        if self.inventory[item_type]:
            for idx, item in enumerate(self.inventory[item_type], 1):
                if item:  # Check if item is not None
                    print(f"{idx}. {item['name']}: {item['description']}")
                else:
                    print("No items in this category.")
                    print("You need to press < to go back.")
            choice = input("")
            if choice == "<":
                self.visit_inventory()
            elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]):
                self.equip_item(item_type, int(choice) - 1)
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(1)
                self.display_items(item_type)
        else:
            print("No items in this category.")
            print("You need to press < to go back.")
            choice = input("")
            if choice == "<":
                self.visit_inventory()
            else:
                print("Invalid option. Please enter < to go back.")
                time.sleep(1)
                self.visit_inventory()
    def equip_item(self, item_type, index):
        if item_type in self.equipped_items:
            if 0 <= index < len(self.inventory[item_type]):
                item = self.inventory[item_type].pop(index)
                if self.equipped_items[item_type]:
                    old_item = self.equipped_items[item_type]
                    self.inventory[item_type].append(old_item)
                self.equipped_items[item_type] = item
                self.update_stats()  # Update stats after equipping any item
                print(f"{item['name']} equipped.")
                time.sleep(1)
            else:
                print("Invalid item index.")
                time.sleep(1)
        else:
            print("Invalid item type.")
            time.sleep(1)

    def apply_item_stats(self, item):
        if 'Attack' in item:
            self.attack += item['Attack']
        if 'Defense' in item:
            self.defense += item['Defense']
        if 'Dodge' in item:
            self.dodge += item['Dodge']
        if 'Speed' in item:
            self.speed += item['Speed']

    def unequip_item(self, item_type_to_swap):
        if self.equipped_items[item_type_to_swap]:
            self.swap_item(item_type_to_swap)
        else:
            print("No item equipped.")
            time.sleep(1)
            self.display_equipped_items()
            

    def unequip_menu(self, item_type_to_swap):
        os.system('cls' if os.name == 'nt' else 'clear')
        print(f"Swap {item_type_to_swap}:")
        print("=" * 40)
        if self.equipped_items[item_type_to_swap]:
            equipped_item = self.equipped_items[item_type_to_swap]
            if 'description' in equipped_item:
                print(f"1. {equipped_item['name']} - {equipped_item['description']}")
            else:
                print(f"1. {equipped_item['name']}")
            print("Enter 1 to swap or press < to cancel.")
            choice = input("")
            if choice == "1":
                self.swap_item(item_type_to_swap)
            elif choice == "<":
                self.display_equipped_items()
            else:
                print("Invalid option. Please enter a valid option.")
                time.sleep(1)
                self.unequip_menu(item_type_to_swap)
        else:
            print(f"No {item_type_to_swap} equipped.")
            time.sleep(1)
            self.display_equipped_items()
            
    def swap_item(self, item_type_to_swap):
        os.system('cls' if os.name == 'nt' else 'clear')
        print(f"Swap {item_type_to_swap}:")
        print("=" * 40)
        if self.inventory[item_type_to_swap]:
            for idx, item in enumerate(self.inventory[item_type_to_swap], 1):
                if item:  # Check if item is not None
                    print(f"{idx}. {item['name']}: {item['description']}")
                else:
                    print("No items in this category.")
                    print("You need to press < to go back.")
            choice = input("")
            if choice == "<":
                self.unequip_menu(item_type_to_swap)
            elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type_to_swap]):
                self.equip_item(item_type_to_swap, int(choice) - 1)
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(1)
                self.swap_item(item_type_to_swap)
        else:
            print("No items in this category.")
            print("You need to press < to go back.")
            choice = input("")
            if choice == "<":
                self.unequip_menu(item_type_to_swap)
            else:
                print("Invalid option. Please enter < to go back.")
                time.sleep(1)
                self.unequip_menu(item_type_to_swap)
            
    def display_equipped_items(self):
        clear_screen()
        print("Equipped Items:")
        print("=" * 40)
        for item_type, item in self.equipped_items.items():
            if item:
                name = item.get('name', 'Unknown')
                description = item.get('description', 'No description')
                print(f"{item_type}: {name} - {description}")
            else:
                print(f"{item_type}: None")
        print("\nUnequip Items:")
        print("=" * 40)
        for i, (item_type, item) in enumerate(self.equipped_items.items(), start=1):
            if item:
                name = item.get('name', 'Unknown')
                description = item.get('description', 'No description')
                print(f"{i}. {item_type}: {name} - {description}")
            else:
                print(f"{i}. {item_type}: None")
        print("Press < to go back to the player status menu.")
        choice = input("")
        if choice == "<":
            self.display_status()
        elif choice.isdigit():
            index = int(choice) - 1
            if 0 <= index < len(self.equipped_items):
                item_type_to_unequip = list(self.equipped_items.keys())[index]
                self.unequip_menu(item_type_to_unequip)
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(1)
                self.display_equipped_items()
        else:
            print("Invalid option. Please enter a valid option.")
            time.sleep(1)
            self.display_equipped_items()
            
    def remove_equipped_item(self, item_type):
        if item_type in self.equipped_items:
            item = self.equipped_items.pop(item_type)
            self.inventory[item_type].append(item)

    def play_game(self):
        clear_screen()
        # Placeholder for play game functionality
        input("Play game functionality is under construction. Press Enter to return to the player status menu...")
        self.display_status()

    def add_experience(self, amount):
        self.experience += amount
        if self.experience >= self.exp_required:
            self.level_up()
        self.display_status()

    def level_up(self):
        self.level += 1
        self.experience = 0
        self.attack += 0.5
        self.defense += 0.5
        self.dodge += 0.5
        self.speed += 0.5
        self.exp_multiplier = 0.25
        self.exp_required = int(self.exp_required * (1 + self.exp_multiplier))  # Update exp required with new multiplier
        
    def equip_item_level_up(self, item):
        if 'Attack' in item:
            self.attack += item['Attack']
        if 'Defense' in item:
            self.defense += item['Defense']
        if 'Dodge' in item:
            self.dodge += item['Dodge']
        if 'Speed' in item:
            self.speed += item['Speed']
            
    def get_name_display(self):
        symbol = ""
        if self.difficulty == "Basic":
            symbol = "🛡️"
        elif self.difficulty == "Exemplar":
            symbol = "⚔️"
        elif self.difficulty == "Templar":
            symbol = "☠️"
        return f"{symbol} {self.name}"

    def get_difficulty_display(self):
        return self.difficulty

    def visit_shop(self):
        clear_screen()
        while True:
            os.system('cls' if os.name == 'nt' else 'clear')
            print("Welcome to the Shop!")
            print("=" * 40)
            print("Shop Sections:")
            print("1. Weapons")
            print("2. Armors")
            print("3. Shields")
            print("4. Footwear")
            print("5. Usable Items")
            print("6. Back to Player Status")
            print("\nEnter the number to select a shop section.")

            choice = input("")

            if choice == "1":
                self.display_shop_section("Weapons")
            elif choice == "2":
                self.display_shop_section("Armors")
            elif choice == "3":
                self.display_shop_section("Shields")
            elif choice == "4":
                self.display_shop_section("Footwear")
            elif choice == "5":
                self.display_shop_section("Usable Items")
            elif choice == "6":
                self.display_status()
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(1)

    def display_shop_section(self, item_type):
        os.system('cls' if os.name == 'nt' else 'clear')
        print(f"Shop - {item_type}:")
        print("=" * 40)
        if item_type in items_groups:
            for idx, item in enumerate(items_groups[item_type], 1):
                print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold")
            print("0. Back to Shop Sections")
            print("Enter the number to purchase the item or 0 to go back.")
            choice = input("")
            if choice == "0":
                self.visit_shop()
            elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]):
                self.purchase_item(item_type, int(choice) - 1)
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(1)
                self.display_shop_section(item_type)
        else:
            print("Invalid shop section.")
            time.sleep(1)
            self.visit_shop()

    def purchase_item(self, item_type, index):
        item = items_groups[item_type][index]
        cost = item['cost']
        if self.gold >= cost:
            self.gold -= cost
            self.inventory[item_type].append(item)
            print(f"You have purchased {item['name']} for {cost} gold.")
            time.sleep(1)
        else:
            print("Insufficient gold to purchase this item.")
            time.sleep(1)
        self.display_shop_section(item_type)
            
items_groups = {
    "Usable Items": [
        {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20},
        {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50},
        {"name": "Moderated Potion", "description": "+25 hp", "cost": 75},
        {"name": "Regen Potion", "description": "+15%", "cost": 100},
        {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55, "Attack": 0.07},
        {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75, "Attack": 0.15},
        {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45, "Defense": 0.07},
        {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60, "Defense": 0.15},
        {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40, "Speed": 2},
        {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55, "Speed": 4},
        {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60, "Dodge": 0.12},
        {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90, "Dodge": 0.23},
        {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60},
        {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120},
        {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200},
        {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400},
        {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50, "Dodge": 0.4},
        {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75, "Dodge": 0.6},
        {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50},
        {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100},
        {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150}
    ],
    "Weapons": [
        {"name": "Stone Sword", "description": "+12 attack", "cost": 150, "Attack": 12},
        {"name": "Copper Sword", "description": "+15 attack", "cost": 275, "Attack": 15},
        {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400, "Attack": 17},
        {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600, "Attack": 23},
        {"name": "Viranium Sword", "description": "+25 attack", "cost": 850, "Attack": 25},
        {"name": "Titanium sword", "description": "+35 attack", "cost": 1250, "Attack": 35}
    ],
    "Armors": [
        {"name": "Jungle sets", "description": "+7 Defense", "cost": 90, "Defense": 7},
        {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140, "Defense": 12},
        {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350, "Defense": 15},
        {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560, "Defense": 25},
        {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850, "Defense": 40}
    ],
    "Shields": [
        {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80, "Dodge": 2},
        {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120, "Dodge": 3, "Defense": 2},
        {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300, "Dodge": 5, "Defense": 4},
        {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550, "Dodge": 7, "Defense": 5, "Attack": 3},
        {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760, "Dodge": 12, "Defense": 7, "Attack": 5}
    ],
    "Footwear": [
        {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45, "Speed": 3},
        {"name": "Iron Foot", "description": "+5 Speed", "cost": 75, "Speed": 5},
        {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120, "Speed": 8},
        {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230, "Speed": 12},
        {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450, "Speed": 19},
        {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700, "Speed": 25}
    ],
    "Weapons None": [
      {"name": "None", "description": "No Weapons Used", "cost" : 0, "Attack": 0}
    ],
    "Armors None": [
      {"name": "None", "description": "Armors Used", "cost" : 0, "Attack": 0}
    ],
    "Shields None": [
      {"name": "None", "description": "No Shields Used", "cost" : 0, "Attack": 0}
    ],
    "Footwear None": [
      {"name": "None", "description": "No Footwears Used", "cost" : 0, "Attack": 0}
    ],
}

def create_character():
    clear_screen()
    print("Character Creation")
    name = input("Enter your character's name: ")
    clear_screen()
    print(f"Character Name: {name}\n")
    
    while True:
        print("Select Difficulty:")
        print("1. Basic 🛡️")
        print("2. Exemplar ⚔️")
        print("3. Templar ☠️")
        difficulty_choice = input("Enter the number to select difficulty: ")
        
        if difficulty_choice == "1":
            difficulty = "Basic"
            description = "Enemies are powerful in their origins."
        elif difficulty_choice == "2":
            difficulty = "Exemplar"
            description = "Enemies are harder and more immortalized."
        elif difficulty_choice == "3":
            difficulty = "Templar"
            description = "Enemies are evils."
        else:
            print("Invalid difficulty choice. Please choose a valid option.")
            time.sleep(1)
            clear_screen()
            continue
        
        clear_screen()
        print("Selected Difficulty:")
        print(f"Name: {name}")
        print(f"Difficulty: {difficulty}")
        print(f"Description: {description}\n")
        print("1. Confirm")
        print("2. Back")
        
        confirm_choice = input("Enter your choice: ")
        if confirm_choice == "1":
            break
        elif confirm_choice == "2":
            clear_screen()
            continue
        else:
            print("Invalid choice. Please enter 1 to confirm or 2 to go back.")
            time.sleep(1)
            clear_screen()

    player = Player(name, difficulty)
    player.equipped_items["Weapons"] = {"name": "Broken Sword", "description": "+10 Damage", "attack": 10}
    player.equipped_items["Armors"] = {"name": "Broken Armor", "description": "+5 Defense", "defense": 5}
    player.equipped_items["Shields"] = {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2}
    player.equipped_items["Footwear"] = {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3}

    return Player(name, difficulty)

def clear_screen():
    """Clears the console screen."""
    os.system('cls' if os.name == 'nt' else 'clear')

def main_menu():
    clear_screen()
    print("BeaVenture\n")
    print("1. Create Character")
    print("2. Exit")
    print("\nEnter the number to select an option.")

def main():
    while True:
        main_menu()
        try:
            choice = int(input(""))

            if choice == 1:
                player = create_character()
                player.display_status()
            elif choice == 2:
                clear_screen()
                print("Exiting BeaVenture. Goodbye!")
                time.sleep(2)
                clear_screen()
                print("Game Was Ended")
                input("Press Enter to exit...")
                clear_screen()
                break
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(2)
        except ValueError:
            print("Invalid input. Please enter a number.")

if __name__ == "__main__":
    main()
content_copyCOPY