ClanGenOfficial / clangen

Warrior Cats fan game
https://clangen.io
Other
229 stars 398 forks source link

[BUGFIX]: patrol only tries to award injuries that the cat doesn't already have #2498

Closed j-gynn closed 1 week ago

j-gynn commented 1 week ago

About The Pull Request

Adds a check to see if the cat already has the chosen injury before attempting to award it. Also adds a guard on that check to ensure that there is a possible injury in the pool for the cat - it throws a warning to the console if not and skips adding any injury, otherwise we'd be stuck in an endless loop forever.

Linked Issues

Fixes #2485

Proof of Testing

Before (test patrol awards scrapes as expected) image

After (Paulina already has scrapes, this outcome should give scrapes but instead gives nothing as there is no other available option for Paulina to get). image

Command line output: image

If multiple injuries are in the pool, it will reroll until it gets something they don't have (I added bruises to this pool and now poor Paulina has those too) image

Changelog/Credits

Bugfix: patrol correctly awards valid injuries to cats with pre-existing minor injuries