8000 Improvement: Introduced Profession SubTypes for Easier Categorization by IllianiBird · Pull Request #6914 · MegaMek/mekhq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improvement: Introduced Profession SubTypes for Easier Categorization #6914

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

Merged
merged 5 commits into from
May 8, 2025

Conversation

IllianiBird
Copy link
Collaborator

Previously we were using a boolean to determine whether a profession was Combat or Not Combat; and then doing some additional checks to determine if the profession is Not Combat and Also Civilian.

Now we just use an enum with three entries: Combat, Support, and Civilian.

This is prep work for a minor GUI adjustment coming separately.

@IllianiBird IllianiBird self-assigned this May 7, 2025
@IllianiBird IllianiBird added Tests Issues or Pull Requests related to the project tests Refactoring labels May 7, 2025
Copy link
codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 11.71%. Comparing base (ab86214) to head (b95cc59).
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #6914   +/-   ##
=========================================
  Coverage     11.71%   11.71%           
- Complexity     6666     6670    +4     
=========================================
  Files          1101     1101           
  Lines        141414   141414           
  Branches      21901    21901           
=========================================
+ Hits          16564    16568    +4     
+ Misses       123146   123145    -1     
+ Partials       1704     1701    -3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the profession categorization by introducing a new enum, PersonnelRoleSubType, to replace the previous boolean combat flag and additional checks. It updates constructors and role methods in PersonnelRole and adds corresponding localized labels in the resources.

  • Introduces the PersonnelRoleSubType enum with three entries: COMBAT, SUPPORT, and CIVILIAN.
  • Updates the PersonnelRole enum constructors, isCombat, isSupport, and isCivilian methods to use the new enum.
  • Adds a properties file for localization labels for the new subtypes.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
MekHQ/src/mekhq/campaign/personnel/enums/PersonnelRoleSubType.java New enum definition to replace boolean flags for role categorization.
MekHQ/src/mekhq/campaign/personnel/enums/PersonnelRole.java Updated role evaluations and constructors to use PersonnelRoleSubType instead of booleans.
MekHQ/resources/mekhq/resources/PersonnelRoleSubType.properties Provides localized labels for the new subtypes.

@@ -554,7 +569,7 @@ public boolean isVesselCrewMember() {
* otherwise.
*/
public boolean isSupport() {
return isSupport(false);
return isSubType(PersonnelRoleSubType.SUPPORT) || isSubType(PersonnelRoleSubType.CIVILIAN);
Copy link
Preview
Copilot AI May 7, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider updating the javadoc comment for isSupport to make clear that the method returns true for roles with either SUPPORT or CIVILIAN subtypes.

Copilot uses AI. Check for mistakes.

@HammerGS
Copy link
Member
HammerGS commented May 8, 2025

@IllianiBird

The failure occurred in the PersonnelRoleTest.testIsSupport() unit test. The logs indicate that an AssertionFailedError occurred at PersonnelRoleTest.java:560, but I was unable to retrieve the PersonnelRoleTest.java file for further analysis. However, I can provide guidance based on the context available.

Analysis
Unit Test Failure:

The testIsSupport() method failed, likely due to an assertion mismatch.
The error in the logs does not provide the specific assertion that failed, so it is necessary to inspect the test code to identify the issue.
Workflow Observations:

The workflow checks out specific branches from related repositories (MegaMek and MegaMekLab), falling back to master if the branch does not exist.
There might be a misalignment between the versions of MegaMek, MegaMekLab, and MekHQ used in the test.
Suggested Solution
Retrieve the PersonnelRoleTest.java file and check the logic in the testIsSupport() method, particularly at or around line 560.
Ensure that the test aligns with the current functionality of the dependent code.
Double-check the configurations and compatibility of related repositories (MegaMek and MegaMekLab) by verifying the branches and commits being used.

@HammerGS HammerGS merged commit 928a225 into MegaMek:master May 8, 2025
6 checks passed
@IllianiBird IllianiBird deleted the professionCategorization branch June 7, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Tests Issues or Pull Requests related to the project tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0