-
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
character: relocate and refactor suffer #35300
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mlangsdorf
added
[C++]
Changes (can be) made in C++. Previously named `Code`
Mechanics: Character / Player
Character / Player mechanics
Code: Infrastructure / Style / Static Analysis
Code internal infrastructure and style
labels
Nov 4, 2019
mlangsdorf
force-pushed
the
refactor_suffer
branch
from
November 4, 2019 14:02
c38de82
to
4d26b3d
Compare
mlangsdorf
force-pushed
the
refactor_suffer
branch
from
November 5, 2019 12:15
603545d
to
307b3a1
Compare
KorGgenT
reviewed
Nov 6, 2019
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.
all right, i read through all of the code, and it looks good overall. just a couple thoughts.
mlangsdorf
force-pushed
the
refactor_suffer
branch
2 times, most recently
from
November 8, 2019 15:08
7aa01fa
to
2b724ed
Compare
Migrate suffer() down from player:: into Character::, along with the minimum but still substantial set of functions and variables that also need to be in Character:: in order to make the code compile.
add in stubs for all the suffer subfunctions, both to establish the future structure and to populate the header file, which will speend up compiles while testing this. Move a few of the simpler bits of code directly into their subfunctions, consolidating some code in the process.
move the code to handle mutation based water damage/healing to a separate function, and move the code to handle mutation power to a separate function. Unify their loops to slightly speed up the performance.
Move the code for drowning out of suffer and into suffer_while_underwater().
split out the code for suffering while awake, including the code for chem imbalance and schizophrenia. Substantially re-order and rework schizophrenia, so that NPCs with schizophrenia will suffer from some of the externally visible effects like dropping weapons.
split out the code for suffering from asthma. Slightly rework the entry conditions for clarity.
Split out the code for suffering in sunlight. Rework it slightly to exit early if the character is not in sunlight, which also simplifies the following if statement. Substantially refactor the entry conditions for albinism for clarity.
Move the radiation handling code into its own function, and slightly change the logic in order to remove a level of indenting and terminate the function earlier.
Move the faulty bionics code into its own function.
Move the stimulant based suffering into its own function.
Move sleep deprivation into its own function. Reverse the order of the logic in the trinary statement to set sleep deprivation, and add a note that the first set of messages should be replaced with some snippets.
mlangsdorf
force-pushed
the
refactor_suffer
branch
from
November 9, 2019 12:23
2b724ed
to
46d0336
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[C++]
Changes (can be) made in C++. Previously named `Code`
Code: Infrastructure / Style / Static Analysis
Code internal infrastructure and style
Mechanics: Character / Player
Character / Player mechanics
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: Infrastructure "character: relocate and refactor suffer"
Purpose of change
player::suffer() is a 1200 line function that should be broken up into several functions and moved
into character::.
Describe the solution
Move suffer() into a new file and make it part of the
Character::
class. Also move some related functions and variables out ofplayer::
and intoCharacter::
to make the new function compile.Split out some of the code from suffer() into smaller functions. Specifically, move the mutation power code and the mutation water damage code into two separate functions, and unify the two loops into a single loop.
Testing
Passed local unit tests.
Spawned an unwilling cyborg with chemical imbalance, schizophrenia, gills, and some other stuff. Waited a bit and observed faulty bionics and schizophrenia and chemical imbalance related messages. Swam in water without drowning, then mutated myself to remove the gills and drowned.
TODO