Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to filter monsters #576

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coopermor
Copy link
Contributor

This adds the ability to filter monsters in the selection through the use of aliases similar to equipment. This is useful as there are many monsters with a plethora of cosmetic variants. Some of the worst offenders are Zombie pirate (Harmony Island) with 26 cosmetic variants or Jelly with 10 cosmetic variants.

In my opinion this is an improvement to the user experience.

Before:
image
After:
image

I'm curious thoughts on the tests. If you like them I can add more. If you don't think they have a value they can be removed. My thought is monsters like Blue dragon#1 could get merged with Blue dragon#Ruins of Tapoyauik, 1 if an error is introduced in the regex. This would be an issue as they do not have the same elemental weakness.

In my first implementation I added a function to determine if a monster is a cosmetic variant. If you would like to see that as a second safeguard after the regex I would be happy to include that.

def is_cosmetic_variant(monsters, candidate):
    for monster in monsters:
        if candidate["name"] != monster["name"]:
            continue
        if (
            candidate["level"] != monster["level"]
            or candidate["speed"] != monster["speed"]
            or candidate["style"] != monster["style"]
            or candidate["size"] != monster["size"]
            or candidate["max_hit"] != monster["max_hit"]
            or candidate["skills"]["atk"] != monster["skills"]["atk"]
            or candidate["skills"]["def"] != monster["skills"]["def"]
            or candidate["skills"]["hp"] != monster["skills"]["hp"]
            or candidate["skills"]["magic"] != monster["skills"]["magic"]
            or candidate["skills"]["ranged"] != monster["skills"]["ranged"]
            or candidate["offensive"]["atk"] != monster["offensive"]["atk"]
            or candidate["offensive"]["magic"] != monster["offensive"]["magic"]
            or candidate["offensive"]["magic_str"] != monster["offensive"]["magic_str"]
            or candidate["offensive"]["ranged"] != monster["offensive"]["ranged"]
            or candidate["offensive"]["ranged_str"] != monster["offensive"]["ranged_str"]
            or candidate["offensive"]["str"] != monster["offensive"]["str"]
            or candidate["defensive"]["crush"] != monster["defensive"]["crush"]
            or candidate["defensive"]["magic"] != monster["defensive"]["magic"]
            or candidate["defensive"]["heavy"] != monster["defensive"]["heavy"]
            or candidate["defensive"]["standard"] != monster["defensive"]["standard"]
            or candidate["defensive"]["light"] != monster["defensive"]["light"]
            or candidate["defensive"]["slash"] != monster["defensive"]["slash"]
            or candidate["defensive"]["stab"] != monster["defensive"]["stab"]
        ):
            return False
        if (candidate["weakness"] is not None
            and monster["weakness"] is not None
            and candidate["weakness"]["element"] != monster["weakness"]["element"]
            and candidate["weakness"]["severity"] != monster["weakness"]["severity"]
        ):
            return False
        if(candidate["attributes"] is not None 
           and monster["attributes"] is not None
           and candidate["attributes"] != monster["attributes"]):
            return False
        return True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant