-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Refactor eating morale modifiers and messages #37713
Refactor eating morale modifiers and messages #37713
Conversation
Morale changes are already (supposedly) handled in `Character::modify_morale`, called by `Character::consume_effects`, but large swaths of `player::eat` were taken up by code exclusively related to morale modification. I'm moving this where I think it belongs. Refactoring to support CleverRaven#7533 I read through all of the code carefully before moving, and used vim to ensure no undefined variables were left around. Tested in-game with various consumables, and ensured the morale bonuses and messages were still correctly displayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very good change. However, some further improvements can be made to the moved code.
@codemime Thanks for the suggestions! I will clean these up the best I can. The part about looking for a nearby table is almost duplicated (along with the multiple invocations of Cataclysm-DDA/src/activity_handlers.cpp Lines 412 to 419 in 6017c7c
Cataclysm-DDA/src/activity_item_handling.cpp Lines 1428 to 1435 in 6017c7c
So it's clear we may need a standalone |
New |
I've done another pass of regression testing and this looks ready to go. There's a travis-ci failure but I don't think I can do anything about it:
|
For symmetry with `map::has_nearby_chair`, possible future re-use, and to simplify the `Character::modify_morale` function slightly.
Co-Authored-By: codemime <codemime@gmail.com>
Summary
SUMMARY: Infrastructure "Move food morale modifiers to modify_morale"
Purpose of change
Purely code refactoring/cleanup - separation of responsibility, and improved readability.
Describe the solution
It moves sections of
player::eat
concerned only with modifying morale to the more appropriate function,Character::modify_morale
, and refactors a couple sections.Describe alternatives you've considered
Considered leaving the morale effects in
player::eat
.Testing
Used vim to ensure no undefined variables were left around.
Regression testing: Used debugging menu in game to mutate / spawn items and eat various morale-modifying foods, and ensure the correct messages and morale effects happened, including but not limited to:
Additional context
This was intended as part of a patch for #7533 but that's a separate problem (and harder for me to solve), so I thought it worthwhile on the basis of cleanup alone.