Skip to content
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

Added Handling for Unsupported Unit Types #5720

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

IllianiCBT
Copy link
Collaborator

  • Added handling for unsupported unit types (currently only Gun Emplacements).

Unsupported unit types are handled in the following manner:

  1. Automatically sold on load (to handle older campaigns).
  2. Blocked from being salvaged.
  3. Blocked from purchase (including GM purchase).

Added functionality to automatically sell unsupported units, such as gun emplacements, upon campaign load. Affected units are listed in a notification to the user, and their assigned personnel are unassigned. Updated resource bundle and supporting methods to accommodate this change.
Excluded gun emplacements from salvage as they are unsupported in MekHQ. This ensures consistency and avoids unintended gameplay behavior during scenario resolution.
Prevented the selection of Gun Emplacement units in MekHQ if they are unsupported. Added a user-facing message indicating the restriction and integrated appropriate resource strings for localization. This ensures better handling of unsupported unit types.
@Sleet01 Sleet01 merged commit 6f22dfb into MegaMek:master Jan 9, 2025
4 checks passed
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.21%. Comparing base (878f61b) to head (16ea3f7).
Report is 73 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5720      +/-   ##
============================================
+ Coverage     10.03%   10.21%   +0.17%     
- Complexity     6069     6070       +1     
============================================
  Files          1074     1009      -65     
  Lines        141525   139242    -2283     
  Branches      20666    20437     -229     
============================================
+ Hits          14209    14221      +12     
+ Misses       125944   123651    -2293     
+ Partials       1372     1370       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +469 to +481
if (!soldUnits.isEmpty()) {
StringBuilder message = new StringBuilder(resources.getString("unsupportedUnits.body"));

for (Unit soldUnit : soldUnits) {
retVal.getQuartermaster().sellUnit(soldUnit);
message.append("- ").append(soldUnit.getName()).append("<br>");
}

JOptionPane.showMessageDialog(null,
String.format("<html>%s</html>", message),
resources.getString("unsupportedUnits.title"),
JOptionPane.WARNING_MESSAGE);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can't be in a static function because it has reference to the resources, which is in the base instance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was fixed a while ago - if you're referring to what I think you are. If you update your master it should be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants