-
Notifications
You must be signed in to change notification settings - Fork 178
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
Prisoner Rework #5948
Prisoner Rework #5948
Conversation
Extracted and centralized prisoner-related logic into a new PrisonerController class to improve modularity. Updated references and imports across the codebase accordingly, and removed unused GUI elements related to prisoner ransoming.
Revised defection chances, adding differentiation for mercenaries and Clan personnel via new logic. Introduced modifiers to adjust probabilities, accounting for faction origins and affiliations such as pirates and mercenaries, with distinct handling for Clan dezgra scenarios. Refactored defection logic into a dedicated `attemptDefection` method.
Implemented a new DefectionOffer dialog to handle player notifications for captured personnel offering defection or declaring as Bondsman. Refactored related prisoner processing logic for clarity and integrated the dialog to display in-character and out-of-character messages. Updated resources with appropriate localized text for the dialog content.
Removed outdated and irrelevant Javadocs that described functionality unrelated to the DefectionOffer class. This cleanup improves code readability and avoids confusion about the class's purpose.
Simplified the code by removing all references to prisoner ransom logic, including related variables, methods, and transactions. This ensures a more streamlined handling of captured prisoners without maintaining unnecessary ransom-related data.
Updated prisoner ransom logic to check for GM status before enabling the option in the context menu. Adjusted the "Ransom" text in the GUI to reflect this GM restriction for clarity.
…ndling. Refactored the class name for clarity and better alignment with its purpose. Added functionality to handle cases where a prisoner is taken as a bondsman, updating campaign reports accordingly.
Implemented a system to handle monthly prisoner ransom events, including distinguishing between friendly POWs and enemy prisoners. Added dialogs to present players with ransom offers and process their decisions, and integrated these events into the daily campaign processing logic.
Updated variable names for clarity in the `rollForMonthlyPrisonerEvent` method. Replaced `eventChance` with `ransomEventChance` to better reflect its purpose and improve code readability.
Replaced boolean combat and convoy force checks with a new ForceType enum, introducing distinct force types (Standard, Support, Convoy, Security). Updated related logic, file I/O, and GUI elements to align with the new structure, improving code readability and extensibility.
Updated copyright notices across multiple files to reflect the extension to 2025. This ensures compliance with copyright requirements and maintains consistency across the project.
Added detailed Javadoc comments for ForceType enum, its fields, methods, and enum values. Updated logger message for invalid ordinal to correctly return the STANDARD type. Improved code clarity and maintainability.
Implemented a method to calculate prisoner capacity based on unit types and updated `getFacilityReport` to include prisoner capacity checks with color-coded limits. Also added a utility method to identify battle armor units for capacity calculations.
Introduced a new field and methods in Campaign to manage temporary prisoner capacity. Updated MonthlyPrisonerEventPicker to include this capacity in its calculation. This enhances flexibility in managing prisoner-related events.
Replaced `rollForMonthlyPrisonerEvent` with `performPrisonerChecks` for streamlined prisoner events and capacity handling. Updated capacity calculations to include temporary values and improved event thresholds for minor and major capacity overloads. Added XML serialization for temporary prisoner capacity.
Implemented a new PrisonerMinorEventDialog that adds minor event handling for prisoners. Refactored the prisoner event system by introducing the PrisonerEventProcessor to replace the old MonthlyPrisonerEventPicker. Improved flexibility in handling prisoner management decisions and expanded support for dynamic event processing and user interaction.
Revised resource keys in `PrisonerMinorEventDialog.java` and properties file to use the "responseMinor" and "eventMinor" naming convention. This improves clarity and distinguishes minor event responses from other types.
Renamed the class, property file, and references to clarify its purpose and align with naming conventions. This change simplifies the codebase and improves consistency across related components.
Made `getPersonalityValue` public and updated the prisoner event dialog to support minor and major event differentiation. Introduced major event response types with success and failure handling. Added logic for escalating minor events and created a system to manage major event responses dynamically.
Moved personality value calculation to PersonalityController for consistency. Adjusted prisoner event logic to include warnings and added distinct dialogs for minor, major, and warning events. Improved button layout and tooltips for better clarity in prisoner dialogs.
Refactored MHQDialogImmersive to simplify layout and improve UI logic, including speaker width handling and button placement. Enhanced prisoner event decisions with detailed success and failure descriptions for better narrative depth. These changes aim to improve code maintainability and user engagement with prisoner event outcomes.
Moved event check logic into a separate method to improve readability and reuse. Updated GUI components for better styling flexibility, scaling, and layout consistency, including dynamic width adjustments and padding enhancements.
Made various grammar corrections, streamlined phrasing, and improved formatting for clarity in the prisoner event dialog properties file. Focused on consistency and readability while preserving the original tone and intent.
Replaced manual initialization of event responses with structured, static maps for major and minor events. Simplified response retrieval logic in `makeEventCheck` by incorporating minor event handling. Removed redundant `buildMajorEventResponses` method, improving code readability and maintainability.
Replaced PrisonerEventProcessor with PrisonerEventManager for better clarity and organization. Introduced new enums (ResponseQuality, EventResultEffect, PrisonerEvent) to improve code structure and event handling. Adjusted affected classes and properties to align with the new logic.
Added a framework for random prisoner events using YAML descriptors and integrated it into the campaign. This includes major and minor event classification, event processing logic, and UI updates for dialogs displaying event choices and results.
Moved `PrisonerEventData` and `PrisonerResponseEntry` to a new `records` package for better organization. Introduced the `EventResult` record to encapsulate event response details, replacing the use of `EventResultEffect` in data models. Updated YAML files and related classes to align with this refactor.
Improved logic for speaker selection in PrisonerEventManager by adding checks for empty security forces. Enhanced the EventResult record with default value handling and JSON annotations. Expanded the PrisonerMajorEventData.yml with detailed event definitions, outcomes, and responses, and refined related UI messages for clarity and consistency.
Replaced method names like `addSupportPoints` and `increaseFatigue` with `changeSupportPoints` and `changeFatigue`, reflecting their dual-purpose functionality (both addition and subtraction). Updated related calls and documentation to align with these changes for improved maintainability.
Replaced "FREE" and "FREE_PERCENT" with "ESCAPE" and "ESCAPE_PERCENT" to better describe prisoner escape scenarios. Adjusted comments to reflect changes, including specifying "xd6" for variable fatigue and crime rolls. Improved event descriptions for consistent terminology across data files.
Implemented `EventEffectsManager` to process and resolve prisoner events, applying effects such as injuries, loyalty changes, or escapes. Updated resource strings for event reporting and integrated support for customized effect handling in the campaign.
Replaced `responseMap` with `responseEntries` across all prisoner event YAML files for consistency with the structure. Adjusted temporary prisoner capacity defaults and calculation logic, alongside improving event-related result reporting and pluralization accuracy. Updated button texts and fixed formatting issues in prisoner event dialog messages.
Corrected mismatched singular/plural logic for death reports in EventEffectsManager. Updated prisoner event dialog to remove redundant information, enhancing message clarity.
Implemented a new Prison Escape Scenario triggered by escaping prisoners. Added support for mob units (Small, Medium, Large, Huge) to represent escapee groups, alongside related logic for unit assignment and mob creation. Enhanced prisoner event handling to track and process escapes.
Refactored `getAvailableForceIDs` to include role restriction bypassing and added fallback logic for empty selections. Modified `PrisonEscapeScenario` to integrate active contracts and generated escapee scenarios with specific templates. Adjusted force handling logic for better alignment with deployment rules and context.
Implemented a new scenario type, Jail Break, with associated logic and XML template. Adjusted scenario generation, force templates, and scenario modifiers to accommodate this type. Also added proper handling of escapee units during Jail Break scenarios and their effects on campaign state.
Moved all prisoner-related classes and enums to the randomEvents.prisoners package for improved organization and clarity. Updated import statements across the project to reflect the new package structure. This change enhances maintainability by grouping similar functionality under a cohesive namespace.
Moved dialog classes and resources related to prisoner events into a structured package for better organization. Extracted MobType enum into its own file and streamlined mob-related logic. Adjusted resource bundle references to align with new naming conventions.
Moved classes from `mekhq.campaign.personnel.randomEvents` to the more generic `mekhq.campaign.randomEvents` package. Adjusted all relevant imports and references across the project to ensure consistency and functionality.
Replaced prisoner management logic with a modular event-based approach. Introduced `PrisonerMissionEndEvent` for handling prisoner scenarios and added detailed decision-making UI dialogs. Deprecated redundant commands like "Make Prisoner of War" and adapted associated resource strings and functionalities.
Introduced a random integer to prisoner dialog event keys to increase variability in key generation. This ensures a more diverse set of outcomes and reduces potential repetitive scenarios.
Introduced a new 'Enemy Bondsman' personnel status, including relevant logic, UI elements, and localization. Extended prisoner handling for mission end events, enabling differentiation between POWs and Bondsmen, and added functionality to recruit prisoner defectors. Updated unit tests to ensure proper behavior.
Corrected a typo in the cancel.button text, replacing a single quotation mark with a pair of single quotation marks for proper string formatting. This ensures consistency and prevents potential issues in text display.
Implemented logic to attempt recovery of Missing in Action (MIA) personnel in campaigns with updated modifiers based on technology. Adjusted prisoner capacity and refined post-scenario handling by removing redundant MIA-to-POW status conversion, now handled by the recovery system.
Updated copyright years to include 2025 where necessary. These changes ensure proper acknowledgment of the project's development timeframe and compliance with licensing requirements.
* @return a {@link Person} <code>List</code> containing all active personnel | ||
*/ | ||
public List<Person> getPrisonerDefectors() { | ||
return getActivePersonnel().stream() |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
Campaign.getActivePersonnel
if (campaignOptions.isUseFieldKitchenIgnoreNonCombatants()) { | ||
personnelCount = campaign.getActiveCombatPersonnel().size(); | ||
} else { | ||
personnelCount = campaign.getActivePersonnel().size(); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
Campaign.getActivePersonnel
int techFaction = isClan ? ITechnology.getCodeFromMMAbbr("CLAN") : ITechnology.getCodeFromMMAbbr("IS"); | ||
try { | ||
// searchingFaction being null is fine because we're just ignoring any exceptions | ||
techFaction = ITechnology.getCodeFromMMAbbr(searchingFaction.getShortName()); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
searchingFaction
this
return ""; | ||
} | ||
|
||
for (int i = 0; i < prisonerCount; i++) { |
Check warning
Code scanning / CodeQL
Constant loop condition Warning
Loop
|
||
String colorOpen = spanOpeningWithCustomColor(MekHQ.getMHQOptions().getFontColorNegativeHexColor()); | ||
|
||
String context = getFormattedTextAt(RESOURCE_BUNDLE, prisonerCount != 1 |
Check warning
Code scanning / CodeQL
Useless comparison test Warning
this condition
? "context.prisoner.plural" | ||
: "context.prisoner.singular"); | ||
|
||
String haveOrHas = getFormattedTextAt(RESOURCE_BUNDLE, prisonerCount != 1 |
Check warning
Code scanning / CodeQL
Useless comparison test Warning
this condition
int techFaction = isClan ? ITechnology.getCodeFromMMAbbr("CLAN") : ITechnology.getCodeFromMMAbbr("IS"); | ||
try { | ||
// searchingFaction being null is fine because we're just ignoring any exceptions | ||
techFaction = ITechnology.getCodeFromMMAbbr(searchingFaction.getShortName()); |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
searchingFaction
this
setAttachedUnitsModifier(scenario, contract); | ||
} | ||
ContractCommandRights commandRights = contract.getCommandRights(); | ||
switch (commandRights) { |
Check warning
Code scanning / CodeQL
Missing enum case in switch Warning
LIAISON
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5948 +/- ##
============================================
- Coverage 10.28% 10.24% -0.04%
- Complexity 6122 6142 +20
============================================
Files 1039 1065 +26
Lines 139358 140530 +1172
Branches 20638 20881 +243
============================================
+ Hits 14334 14404 +70
- Misses 123615 124711 +1096
- Partials 1409 1415 +6 ☔ View full report in Codecov by Sentry. |
# Conflicts: # MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
This represents the WIP prisoner rework. It is not ready for review, I popped it up so that I could get it reviewed by CodeQL.