Preview:
import os
import time
import sys

class Player:
    def __init__(self, name, difficulty):
        self.name = name
        self.difficulty = difficulty
        self.attack = 10
        self.defense = 5
        self.dodge = 2
        self.speed = 3
        self.gold = 100
        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": None,
            "Armors": None,
            "Shields": None,
            "Footwear": None
        }

        self.max_inventory_slots = 30

    # Existing methods...

    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 base stats
        self.attack = 10
        self.defense = 5
        self.dodge = 2
        self.speed = 3
        
        # Add bonuses from equipped items
        for item_type, item in self.equipped_items.items():
            if item:
                self.attack += item.get('attack', 0)
                self.defense += item.get('defense', 0)
                self.dodge += item.get('dodge', 0)
                self.speed += item.get('speed', 0)
                
    def display_status(self):
        os.system('cls' if os.name == 'nt' else 'clear')
        print("Player Status:\n")
        print("="*40)
        print(f"Name: {self.get_name_display()}")
        print(f"Difficulty: {self.get_difficulty_display()}")
        print("-"*40)
        print("Stats:")
        print(f"HP      :❤️{self.calculate_stat('attack')}")
        print(f"Defense :🛡️{self.calculate_stat('defense')}")
        print(f"Attack  :⚔️{self.calculate_stat('attack')}")
        print(f"Dodge   :🤺{self.calculate_stat('dodge')}")
        print(f"Speed   :🏃{self.calculate_stat('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. Play Game")
        print("4. Delete this Character")
        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.play_game()
        elif choice == "4":
            return
        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):
                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":
                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):
        item = self.inventory[item_type].pop(index)
        if item_type in ["Weapons", "Armors", "Shields", "Footwear"]:
            self.remove_equipped_item(item_type)
            self.equipped_items[item_type] = item
            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 play_game(self):
        # 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.exp_required = int(self.exp_required * (1 + self.exp_multiplier))  # Increase by 75%
        self.attack += 0.5
        self.defense += 0.5
        self.dodge += 0.5
        self.speed += 0.5

    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):
        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},
        {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75},
        {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45},
        {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60},
        {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40},
        {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55},
        {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60},
        {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90},
        {"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},
        {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75},
        {"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},
        {"name": "Copper Sword", "description": "+15 attack", "cost": 275},
        {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400},
        {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600},
        {"name": "Viranium Sword", "description": "+25 attack", "cost": 850},
        {"name": "Titanium sword", "description": "+35 attack", "cost": 1250}
    ],
    "Armors": [
        {"name": "Jungle sets", "description": "+7 Defense", "cost": 90},
        {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140},
        {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350},
        {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560},
        {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850}
    ],
    "Shields": [
        {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80},
        {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120},
        {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300},
        {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550},
        {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760}
    ],
    "Footwear": [
        {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45},
        {"name": "Iron Foot", "description": "+5 Speed", "cost": 75},
        {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120},
        {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230},
        {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450},
        {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700}
    ]
}


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()

    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()
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter