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
        self.cleared_chapters = ["The Cave of Loir"]  # Chapter 1 is unlocked by default
        self.chapter_stages = {
            "The Cave of Loir": ["⚔ïļ"] + ["X"] * 9,  # First stage unlocked
            "The Forest Of Azure": ["X"] * 10,  # Locked
            "The Cursed Lake": ["X"] * 10,  # Locked
            "The Baptisted Temple": ["X"] * 10,  # Locked
            "Dungeon": ["X"] * 10,  # Locked
            "Dragon Lair": ["X"] * 10  # Locked
        }
        
    # 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.attack}")
        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. Play Game")
        print("4. Delete this Character")
        print("5. 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.play_game()
        elif choice == "4":
            return
        elif choice == "5":
            self.add_experience(50)
        else:
            print("Invalid option. Please enter a valid number.")
            time.sleep(1)
            self.display_status()
            
    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 get_chapter_name_by_number(self, number):
        chapters = {
            "1": "The Cave of Loir",
            "2": "The Forest Of Azure",
            "3": "The Cursed Lake",
            "4": "The Baptisted Temple",
            "5": "Dungeon",
            "6": "Dragon Lair"
        }
        return chapters.get(number)

    def play_game(self):
        while True:
            clear_screen()
            print("Select Chapter to Play:")
            for i, (chapter_name, stages) in enumerate(self.chapter_stages.items(), start=1):
                if "✔ïļ" in stages:
                    print(f"< ✅ {i} > {chapter_name}")  # Display cleared chapters with a checkmark
                elif "⚔ïļ" in stages:
                    print(f"< {'⚔ïļ'} {i} > {chapter_name}")  # Display unlocked chapters with a sword symbol
                else:
                    print(f"< 🔒 {i} > {chapter_name}")  # Display locked chapters with a lock symbol
            print("< <  Back to Player Status")

            choice = input("Enter the number to select a chapter or < to go back: ")

            if choice == "<":
                self.display_status()  # Fixed: Go back to player status menu
            elif choice.isdigit():
                chapter_index = int(choice) - 1
                if 0 <= chapter_index < len(self.chapter_stages):
                    chapter_name = list(self.chapter_stages.keys())[chapter_index]
                    stages = self.chapter_stages[chapter_name]
                    if "⚔ïļ" in stages:
                        self.play_chapter(chapter_name)
                    elif "✔ïļ" in stages:
                        print("You have already cleared this chapter. Select another chapter to play.")
                        time.sleep(1)
                    else:
                        print("This chapter is locked. Please clear the previous chapters first.")
                        time.sleep(1)
                else:
                    print("Invalid option. Please enter a valid number.")
                    time.sleep(1)
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(1)


    def play_chapter(self, chapter_name):
        while True:
            clear_screen()
            print(f"Chapter: {chapter_name}")
            print("Stages:")
            for i, stage in enumerate(self.chapter_stages[chapter_name], start=1):
                print(f"Stage {i}: {'⚔ïļ' if stage == '⚔ïļ' else '🔒' if stage == 'X' else '✅'}")
            print("< <  Back to Chapter Selection")

            choice = input("Enter the number to select a stage or < to go back: ")

            if choice == "<":
                break
            elif choice.isdigit():
                stage_index = int(choice) - 1
                if 0 <= stage_index < len(self.chapter_stages[chapter_name]):
                    if self.chapter_stages[chapter_name][stage_index] == "⚔ïļ":
                        self.play_stage(chapter_name, stage_index)
                    elif self.chapter_stages[chapter_name][stage_index] == "X":
                        print("This stage is locked. Please clear the previous stages first.")
                        time.sleep(2)
                    else:
                        print("You have already cleared this stage.")
                        time.sleep(1)
                else:
                    print("Invalid option. Please enter a valid number.")
                    time.sleep(1)
            else:
                print("Invalid option. Please enter a valid number.")
                time.sleep(1)

    def play_stage(self, chapter_name, stage_index):
        clear_screen()
        print(f"Chapter: {chapter_name}")
        print(f"Stage: {stage_index + 1}")
        print("Placeholder for gameplay")  # Placeholder for actual gameplay
        if stage_index < len(self.chapter_stages[chapter_name]) - 1:
            self.chapter_stages[chapter_name][stage_index + 1] = "⚔ïļ"  # Unlock next stage
        else:
            self.chapter_stages[chapter_name] = ["✔ïļ"] * 10 # All stages cleared, lock the chapter
            next_chapter_index = list(self.chapter_stages.keys()).index(chapter_name) + 1
            if next_chapter_index < len(self.chapter_stages):
                next_chapter_name = list(self.chapter_stages.keys())[next_chapter_index]
                self.chapter_stages[next_chapter_name][0] = "⚔ïļ"  # Unlock next chapter
                print(f"You cleared {chapter_name}! \nNext chapter unlocked: {next_chapter_name}")
                time.sleep(3)
            else:
                print(f"You cleared {chapter_name} and completed all chapters!")
                time.sleep(3)
        self.chapter_stages[chapter_name][stage_index] = "✅"  # Mark stage as cleared
        time.sleep(2)

        
    def display_locked_message(self, chapter_name):
        clear_screen()
        if self.chapter_stages[chapter_name][0] == "✔ïļ":
            print("You have played for:", self.get_play_time())
        else:
            print("This chapter is locked. Please clear the previous chapters first.")
        input("Press Enter to go back to the selecting chapter.")

    def get_play_time(self):
        return "10 hours 30 minutes"
                
    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