-
Notifications
You must be signed in to change notification settings - Fork 173
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
Relationship & Childhood Overhaul #4521
Relationship & Childhood Overhaul #4521
Conversation
Implemented a new feature to simulate relationship histories, including marriage, procreation, and divorce for new campaign personnel. Enhanced the settings panel to include options for this new feature.
Previously, the system did not correctly handle clan members when simulating relationship history. Added a check to exclude clan members from simulated relationship history updates.
Replaced `PercentageRandomProcreation` with `randomProcreation` across multiple files to change the logic from percentage-based to dice roll-based. Adjusted test cases and method calls to reflect this change, ensuring consistent functionality.
…sts and codebase
Changed the procreation process to occur weekly instead of daily throughout the codebase. This will help reduce the advance day loan on larger campaigns.
Changed the duration adjustment for starting simulations to use weeks. This should reduce load by approximately 85%
Replaced percentage-based random marriage with a dice-roll method. Converted existing percentage configurations to dice size configurations.
Replaced the percentage-based random divorce method with a dice roll system.
Marked the `useRandomSameSexMarriages` option as deprecated and removed its handling from various parts of the code. Legacy support was added to ensure compatibility with versions prior to 50.0.
Renamed several panels for clarity. Removed terms like "Percentage" and "Unofficial" and standardized titles related to "Random Marriage" and "Random Dice".
Increased the dice sizes for random marriages and procreation to create more diverse outcomes. Also added a preliminary system to simulate failed relationships in both opposite-sex and same-sex marriages.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4521 +/- ##
============================================
- Coverage 10.31% 10.30% -0.01%
- Complexity 5872 5893 +21
============================================
Files 944 944
Lines 131403 131760 +357
Branches 19064 19160 +96
============================================
+ Hits 13548 13575 +27
- Misses 116539 116848 +309
- Partials 1316 1337 +21 ☔ View full report in Codecov by Sentry. |
Consolidated `randomOppositeSexDivorce` and `randomSameSexDivorce` into `randomDivorce`. Updated method calls and test cases to reflect this change. Fixed class name for `RandomProcreation` to adhere to naming conventions.
Consolidated opposite and same-sex marriage logic into a single `randomMarriage` method and removed redundant configurations for different dice sizes. Updated tests and configuration files to reflect the new structure. This streamlines the marriage processing logic and reduces duplication.
Simplified the logic for random procreation by removing the multiplier. Instead, we use check to change desire to conceive during the procreation process.
Removed the `useRandomSameSexMarriages` property and its corresponding getter and setter methods from `AbstractMarriage.java`.
Removed unnecessary checks for same-sex marriages and procreation due to age in unit tests and properties.
Implemented a new option to set the dice size for same-sex random marriages independently of opposite-sex marriages. Also adjusted the logic in related classes to handle the new dice size and updated UI components to reflect this change.
Introduced functionality to determine whether a random marriage is within or outside the campaign unit. Added new configuration options and updated methods to handle inter-unit marriage scenarios. Modified the validation and recruitment processes to accommodate newly generated spouses outside the unit.
Corrected the age calculation to ensure external spouses fall within the appropriate age range relative to the person.
Added the logger using MMLogger in Person and CampaignXmlParser classes, replacing LogManager. Introduced a new attribute `joinedCampaign` in Person class, along with getter and setter methods. Updated associated methods and serialization to handle this new attribute. Adjusted default values in CampaignOptions to address marriage and procreation dice sizes.
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.
Tested and seems to work
# Conflicts: # MekHQ/src/mekhq/campaign/Campaign.java # MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java
# Conflicts: # MekHQ/src/mekhq/gui/CampaignGUI.java
# Conflicts: # MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties # MekHQ/src/mekhq/campaign/CampaignOptions.java # MekHQ/src/mekhq/campaign/mission/AtBContract.java # MekHQ/src/mekhq/campaign/personnel/Person.java # MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java # MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java
MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java
Dismissed
Show dismissed
Hide dismissed
Removed the Person parameter from various randomMarriage and randomDivorce methods for consistency and simplicity. Updated corresponding method calls and test cases to reflect these changes. This refactor reduces redundant code and improves method clarity.
# Conflicts: # MekHQ/resources/mekhq/resources/GUI.properties # MekHQ/src/mekhq/campaign/Campaign.java # MekHQ/src/mekhq/campaign/CampaignOptions.java # MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java # MekHQ/src/mekhq/campaign/mission/BotForceRandomizer.java # MekHQ/src/mekhq/campaign/personnel/enums/PersonnelStatus.java # MekHQ/src/mekhq/campaign/personnel/familyTree/Genealogy.java # MekHQ/src/mekhq/campaign/personnel/generator/DefaultPersonnelGenerator.java # MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java # MekHQ/src/mekhq/campaign/universe/generators/companyGenerators/AbstractCompanyGenerator.java # MekHQ/src/mekhq/gui/CampaignGUI.java # MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java # MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java # MekHQ/src/mekhq/gui/dialog/GMToolsDialog.java # MekHQ/src/mekhq/gui/dialog/HireBulkPersonnelDialog.java # MekHQ/src/mekhq/gui/enums/PersonnelFilter.java # MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java # MekHQ/src/mekhq/gui/view/PersonViewPanel.java # MekHQ/unittests/mekhq/campaign/personnel/enums/PersonnelStatusTest.java
Removed redundant @SuppressWarnings annotations from multiple classes and enhanced codebase documentation. The changes add clarity to the functionality of classes and methods through JavaDocs, improving maintainability and readability.
Removed redundant @SuppressWarnings annotations from multiple classes and enhanced codebase documentation. The changes add clarity to the functionality of classes and methods through JavaDocs, improving maintainability and readability.
…relationships_doubleToInt
I've gone through and updated this to work with all the changes made in (and since) the name compliance project. I've also checked to ensure there are no uses of prohibited terms. I've added JavaDocs where they were obviously missing, but I've probably missed a few. As this PR pre-dates the recent style changes, and due to the size of it, I ask that it be grandfathered in. If that's not possible I'll review this and do what I can to shore up any I missed. With all that in mind, given the large volume of conflicts there are probably some stuff that's ended up being a little weird. I tried to catch as much as I could, but I think at this point it's better to fix any remaining issues after merge. Assuming they don't get caught during the review period. Flipping this to live. |
Apologies, these might come too late but I only saw this particular issue today. I would suggest consideration be given to data from: |
@rjhancock GitHub told me you left a comment, but for whatever reason I can't find the comment itself. The file you tagged was just renamed, not a new file, so includes the origin year in the copyright statement. I don't know if you realized the same thing and deleted your comment, or whether GitHub is being weird, so figured I'd respond for completeness sake. |
While this is super interesting data, currently I've no plans to revisit the numbers included in this PR as that would require a bunch of extra testing to make sure they have the right play-feel. However, once this PR is merged all these numbers are campaign options so can be very easily adjusted for your personal games. :) |
That is exactly what happened. I realized what it was and deleted the comment. lol |
Added color-coded messaging to ensure random death events are highly noticeable to users. Imported necessary utilities and refined new day processing to utilize the enhanced reporting mechanism.
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.
Can't speak to the code but everything else I'm good with.
This has picked up conflicts |
Yeah, it does that |
# Conflicts: # MekHQ/resources/mekhq/resources/GUI.properties # MekHQ/src/mekhq/campaign/Campaign.java # MekHQ/src/mekhq/gui/CampaignGUI.java
Removed unused imports for PercentageRandomDivorce and PercentageRandomMarriage. This cleanup improves code readability and reduces unnecessary dependencies in the CampaignGUI class.
Fixed the conflicts |
Not For Inclusion in 50.0
This PR is intended for 50.01 and should not be merged into 50.0.
Introduction
This PR came about as the result of spotting some unusual relationship behaviors while working on #4512. Namely, that some events seemed weirdly common (procreation) while others were exceptionally rare (divorce). I'll be honest here, I've long had a vendetta with our original procreation chances, ever since I had all the women in a campaign fall pregnant on the way to their first contract.
Initially, I made a few changes with a mind to switching from relationship events (marriage, divorce, procreation) using teeny tiny percentages to using variable dice sizes. This system was trialed in the Education Module, where the user defines how many sides an imaginary dice has, then the event occurs on a roll of
1
. It is my belief that this makes predicting how often an event will occur much easier and removes the need for the aforementioned tiny percentages previously used.However, this PR really should just be titled Feature Creep: A Study in Scope Failure, because what was initially some small changes turned into an entire relationship overhaul as I noticed more and more problems with our current systems. And due to how interconnected they were, turned into a childhood overhaul too (though that, at least, was less comprehensive). I'm going to attempt to provide an overview of all the changes made, but they're expansive so I may end up missing something. If you do notice something missing, drop a comment and I'll be happy to provide an explanation.
Relationships
Relationship Events
There are three relationship events currently included in mhq: marriage, divorce, and procreation. The move from percentages to dice rolls allowed me to make a full review of how these events are handled, because their original values were a little wonky.
Furthermore, I changed relationship events to be checked on a weekly basis, rather than daily. This can be logic'd as the news of the event only appearing in the commander's weekly report, rather than daily. While I appreciate the extra nuance daily checks provide, the amount of new day processing required is reduced by around 85% when switching to weekly checks. Given the increased focus on personnel recently, I want to take the load savings where I can.
The chance of same-sex marriage has been adjusted to use a dice-roll, instead of a binary enabled/disabled option. This allows users to specify what percentage of marriages will be same-sex (where possible), or disable same-sex marriage entirely. Campaigns that previously had same-sex marriage disabled will automatically have it disabled when updating to the new version, however presets will need to be updated.
The default value has been based on the 2022 US census. We used the 2022 US census a lot when determining the default values for many of the new options, due to the availability and uniformity of that data.
In Relationship Procreation Chances (per year, per person): was 18.1%, now 9.9%
Out of a Relationship Procreation Chances (per year, per person): was 1.8%, now 2.57%
Marriage Chances (opposite sex, per person) (per 3 years): was 18.2%, now 3.07%
Marriage Chances (same sex, per person) (per 3 years): was 0.73%, now 0.23% (this is derived from 7.4% of marriages being same sex, exact value is dependent on the chance of opposite sex marriage, this value was taken from the 2022 US census).
Divorce Chances (per 10 years, per marriage): was 0.73%, now 43.9%
External Marriage
Marriage is being handled a bit differently now. Previously, whenever a marriage event occurred the marriage would always be between two characters already existing in the campaign. Now, there is only a 10% chance (per marriage event, value campaign option configurable) of that happening. In all other instances a dependent will be conjured out of thin air for them to marry instead.
Maternity Leave
Pregnant characters can optionally go on maternity leave 20 weeks before giving birth and will return to active duty 6 weeks after their child has been born.
Divorce
Divorces can be messy, now when a character experiences a divorce any spouses marked as Dependents will automatically leave the campaign. Non-Dependents have a chance of leaving the campaign. Spouses leaving the campaign may take some (or all) of their children with them.
Flags
The 'marriageable' and 'trying to conceive' flags have been renamed to 'interested in marriage' and 'interested in children' respectively. Also, characters now have the possibility of spawning with no interest in marriage and/or having children. The chances of each can be configured in Campaign Options and the results can be overwritten by changing the flag on any given character.
Furthermore, when a character has a child there is a chance their 'interested in children' flag will be revoked. This is a fixed 1 in 3 chance, but can be overwritten in the same manner as above. This is to try and reduce the overly large families that can result from relying just on dice rolls, but without entirely removing the possibility of those families.
Similarly, when a character has a divorce there is a 1 in 3 chance their 'interested in marriage' flag will be revoked.
Simulated Relationship History
As part of my incremental work towards introducing dynamic backgrounds for characters I have added the option to simulate a characters' romantic history prior to their joining the campaign. This means when a character joins the campaign they may do so having already experienced any number of relationship events. They will also arrive with their family in tow, providing more context to why dependents are with the campaign. When they leave the campaign, their family will follow (exception: adult children may choose to remain with the campaign). This is designed to work alongside #4463, to avoid having campaigns flooded with Dependents.
Characters that don't join the campaign, for example former spouses, will still appear in a characters genealogy but will remain background characters that do not join the campaign.
This feature was originally pushes separately (#4512) however the interactions between that and this PR meant it would have been a nightmare to keep conflict free had they remained separate.
Gender
I have implemented the option for characters to spawn with their gender marked as 'other'. This functionality was (mostly) already written into our gender system, but hadn't been fully implemented until now.
Childhood
Adoption
It is now possible to adopt any child character who doesn't have a living parent. Simply right click on the character wanting to adopt one of the campaigns' orphans and then select the relevant orphan. Characters with a spouse adopting a child will cause the child to be adopted by both characters.
Child Soldiers
Children (defined as any character under the age of 18) are no longer able to be assigned to combat or support roles. Characters in campaigns who already have those roles will be grandfathered in and will not have those roles removed.
Child SPA & Small Arms
There was a bug that was causing Children to be treated as soldiers when spawning, meaning they often ended up with decent Small Arms. That has now been addressed. Children are no longer included in the calculations that dish out Small Arms, though they may still get random skills as normal (which might include small arms).
However, the code that reduced skills for young characters has been more consistently implemented meaning all instances of child spawning now reduce skills according to the characters' age.
Furthermore, there was a bug that caused SPAs to be handed out based on skills possessed by a character prior to age reductions. This predominately affected Mass Recruitment. What could happen, then, is the character spawn with an Elite experience level, causing them to get the bonus SPA rolls from being Elite. Their skills would be removed (whenever that worked properly) based on age, but the SPAs would remain. SPAs are now updated based on a characters' final experience level, when recruiting.
Documentation
Documentation does not currently exist for this overhaul, but will be added at a later date once I'm certain everything is working and isn't in flux.