Show messages when pet is captured or released #37487
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Interface "Show animal capture/release messages on success"
Purpose of change
I wanted to see success messages when capturing or releasing pets from a pet carrier, such as:
Describe the solution
Following the example of similar log messages in these functions, I added one message for successful capture, and one for successful release.
This commit was going to be a simple two-line addition, but I discovered that
release_monster
was deleting the name of the contained animal as part of releasing it, thus I got an empty string when trying to log it.The solution, setting a local
contained_name
variable to remember the animal name, had a nice side-effect of making several other lines a little cleaner and more readable after slight refactoring, so I am including that too.Describe alternatives you've considered
Considered leaving as-is, but capturing even a tame animal is no easy task, and is worth mentioning.
Testing
Tested with debug spawning, pet carrier, cat, and Chihuahua (plus food to make them friendly. Captured and released from the carrier, and got nice messages about it.
Additional context
Sample message output with a cat and Chihuahua: