Skip to content

Add the ability to filter monsters#576

Open
coopermor wants to merge 1 commit intoweirdgloop:mainfrom
coopermor:monster-filtering
Open

Add the ability to filter monsters#576
coopermor wants to merge 1 commit intoweirdgloop:mainfrom
coopermor:monster-filtering

Conversation

@coopermor
Copy link
Copy Markdown
Collaborator

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

@jayktaylor
Copy link
Copy Markdown
Member

Hey, thanks! I'll try and get around to reviewing this within the next couple of weeks.

Copy link
Copy Markdown
Member

@jayktaylor jayktaylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, it's probably a good idea to also add the check you mentioned before to ensure that we're not removing anything that has differing stats.

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.

2 participants