• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Resource icon

v21.1 Python Pokemon Sorter Script 1.69

This resource pertains to version 21.1 of Pokémon Essentials.
Pokémon Essentials Version
v21 ➖
I heard you like SORTING ALGORITHMS? Well, after making my Python Script to rebalance all Pokemon by automatically multiplying their stats with a multiplier cap of 1.5x and a BST cap of 600, I wanted to check which Pokemon have the highest stats, and which ones have the lowest. So I created this!

Just create a new text file in your PBS folder containing the following code.

Code:
Expand Collapse Copy
import pprint

def extract_characters(file_name):
    characters = []
    try:
        with open(file_name, 'r') as file:
            name = None
            base_stats = None
            for line in file:
                if line.startswith("Name = "):
                    if name and base_stats:
                        characters.append((name, base_stats))
                    name = line.strip()[7:]
                    base_stats = None
                elif line.startswith("BaseStats = "):
                    try:
                        base_stats = [int(stat) for stat in line.strip()[11:].split(",")]
                    except ValueError:
                        base_stats = None  # Invalid base stats, ignore this character entry
            if name and base_stats:
                characters.append((name, base_stats))
    except FileNotFoundError:
        print("Error: File not found.")
        return None
    except Exception as e:
        print(f"An error occurred: {e}")
        return None
    return characters


def sort_characters(characters, sort_stat, reverse=False):
    try:
        index = ["HP", "Attack", "Defense", "Speed", "Magic", "Resistance"].index(sort_stat)
        return sorted(characters, key=lambda x: x[1][index], reverse=reverse)
    except ValueError:
        print("Invalid base stat. Please choose from the available options.")
        return None


def print_characters(characters):
    for name, base_stats in characters:
        print(f"{name}: {base_stats}")


if __name__ == "__main__":
    input_file = "pokemon.txt"
    characters = extract_characters(input_file)

    if not characters:
        print("No valid characters found in the file.")
    else:
        print("Available base stats: HP, Attack, Defense, Speed, Magic, Resistance")
        sort_stat = input("Enter the base stat you want to sort by: ")

        sorted_characters = sort_characters(characters, sort_stat, reverse=True)
        if sorted_characters:
            print(f"\nSorted Characters (Descending by {sort_stat}):")
            print_characters(sorted_characters)

    input("Press Enter to exit...")

And rename the script file from "New Text Document.txt" to "Pokemon Sorter Script.py".

Run the script and you'll see this:

Just type in the name of your chosen stat and hit Enter, and all the Pokemon in your game will be sorted from highest to lowest!

This script is Caps-Sensitive, so Remember to Capitalize the Stat's Name! Note that Special Attack and Special Defense in this script are renamed to Magic and Resistance respectively to make them faster to type.

Every time you want to sort your Pokemon by another stat, you'll have to close and reopen the Python Sorter Script.
Credits
SuperSpyroDragon64
Author
SuperSpyroDragon64
Views
1,192
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from SuperSpyroDragon64

Back
Top