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
ChoiceManager refactoring #771
Conversation
Codecov Report
@@ Coverage Diff @@
## main #771 +/- ##
============================================
+ Coverage 24.27% 24.52% +0.25%
- Complexity 10897 10900 +3
============================================
Files 1014 1016 +2
Lines 158244 158760 +516
Branches 34990 34980 -10
============================================
+ Hits 38406 38939 +533
+ Misses 112839 112814 -25
- Partials 6999 7007 +8
Continue to review full report at Codecov.
|
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.
nice to see moving away from Object[][]
:)
I think this is good to go. |
ChoiceManager is unwieldy. It is gigantic. I split it into three separate files:
ChoiceManager.java
This contains the various control flow variables - ChoiceManager.handlingChoice, ChoiceManager.lastChoice, ChoiceManager.lastResponseText, and so on - we are familiar with.
It contains the various methods called by GenericRequest - preChoice, postChoice0, postChoice1, postChoice2, visitChoice, registerRequest - to update those variables appropriately.
It also contains the code for automating choices via CHOICE_HANDLER.
All of the choice-specific code has been moved to ChoiceControl, with the exception of the automation code that knows how to choose "appropriate" decisions for specific choices based on current play state.
ChoiceControl.java
This contains the massive switch statements which used to be in postChoice1, visitChoice, and the other control flow methods called by GenericRequest.
ChoiceAdventures.java
This contains the data for all the choices we support in the GUI (with "whichchoiceXXXX" properties - used for automation) or in the Relay Browser (choice spoilers).
In addition to refactoring the massive file into three coherent modules, I made the following improvements:
My testing looks good, so far. The GUI for choices is unchanged. I see choice spoilers in the Relay Browser. I'm going to test more tomorrow (well, today. After I sleep. :)
I'm marking this ready to review, in case anybody wants to get a head start with it and give me comments.