Fix playing generic game not spending battery charges #46693
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: Bugfixes "Fix playing generic game not spending battery charges"
Purpose of change
Handheld game system is not spending battery charges when a generic game is played. Looking at the code in activity_handlers.cpp,
activity_handlers::game_do_turn()
has battery code but it's completely lacking inactivity_handlers::generic_game_do_turn()
.Thought I'd fix it because I'm playing games to pass time while listening to music to boost my focus while learning from books 😃
Describe the solution
Generic game handling code is extracted as
then both
activity_handlers::generic_game_do_turn()
andactivity_handlers::game_do_turn()
call it with different morale arguments. Values remain the same as before the fix.Also had to add activity target in
iuse::portable_game()
because it was skipped by an early return when playing a generic game.Describe alternatives you've considered
At first I thought I'd have
activity_handlers::generic_game_do_turn()
take additional parametersmorale_bonus
andmorale_max_bonus
with default values, then call it fromactivity_handlers::game_do_turn()
, but it turns out real activity handlers called directly to handle an activity must have a specific signature, so I opted to extract the common logic as a separate function instead.Testing
Loading my save with a handheld game system at the ready and tested following scenarios:
Ran unit tests. Looks like activity handlers are not covered. There's a spelling failure unrelated to my changes.