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

PersonnelRole Enum #2352

Merged
merged 16 commits into from
Apr 27, 2021

Conversation

Windchild292
Copy link
Contributor

@Windchild292 Windchild292 commented Jan 8, 2021

This PR implements PersonnelRole as an Enum, a grouping of role-related bugfixes, and adds the basis of the Dependent Role. There will be more changes in future for this role, and there may be bugs for it. However, I believe the bugs are minimal as part of the larger implementation and they will be fixed in the near future as I move to a full rollout of the dependent role alongside #1886.

To review:
0.47.X: Do not.
Post-0.48.0: The goal is for this to be merged in for 0.49.0.

State:

  • PersonnelRole Enum
  • Dependent Role Baseline
  • PersonnelRole Enum Migration
  • PersonnelRole Enum-based Array Migration
  • Fix Unit Testing

@Windchild292 Windchild292 added Bug (RFE) Enhancement Requests for Enhancement, new features or implementations labels Jan 8, 2021
@Windchild292 Windchild292 added this to the 0.49-dev milestone Jan 8, 2021
@Windchild292 Windchild292 self-assigned this Jan 8, 2021
@@ -2536,16 +2270,15 @@ public int hashCode() {
}

public int getExperienceLevel(boolean secondary) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not certain the logic for this method should stay here or be moved to the PersonnelRole Enum given how much it relies on the latter, but the heavy reliance on Personnel is why I've kept it here.

MekHQ/src/mekhq/campaign/personnel/Person.java Outdated Show resolved Hide resolved
*/
public static boolean isSupportRole(int role) {
return (role >= T_MECH_TECH) && (role < T_LAM_PILOT);
public boolean hasSupportRole(boolean excludeUnmarketable) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Key note for review: the boolean has been flipped, so anyone using the former value will be doing so incorrectly.

@Windchild292 Windchild292 added the Hydra This will require significant changes across the entire project, likely causing unforeseen bugs. label Jan 8, 2021
@codecov
Copy link

codecov bot commented Jan 8, 2021

Codecov Report

Merging #2352 (118f72c) into master (67c4026) will increase coverage by 0.06%.
The diff coverage is 9.41%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2352      +/-   ##
============================================
+ Coverage     10.65%   10.71%   +0.06%     
- Complexity     3740     3763      +23     
============================================
  Files           692      693       +1     
  Lines         97250    97239      -11     
  Branches      16287    16276      -11     
============================================
+ Hits          10364    10424      +60     
+ Misses        85514    85456      -58     
+ Partials       1372     1359      -13     
Impacted Files Coverage Δ Complexity Δ
MekHQ/src/mekhq/Utilities.java 7.66% <0.00%> (+0.01%) 19.00 <0.00> (ø)
MekHQ/src/mekhq/campaign/CampaignSummary.java 49.01% <0.00%> (+0.47%) 4.00 <0.00> (ø)
MekHQ/src/mekhq/campaign/GamePreset.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
MekHQ/src/mekhq/campaign/MercRosterAccess.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...kHQ/src/mekhq/campaign/ResolveScenarioTracker.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...mekhq/campaign/againstTheBot/AtBConfiguration.java 38.72% <0.00%> (ø) 40.00 <0.00> (ø)
MekHQ/src/mekhq/campaign/finances/Accountant.java 16.27% <0.00%> (ø) 7.00 <0.00> (ø)
MekHQ/src/mekhq/campaign/handler/XPHandler.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
MekHQ/src/mekhq/campaign/io/CampaignXmlParser.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...rc/mekhq/campaign/market/PersonnelMarketDylan.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67c4026...118f72c. Read the comment docs.

…tion of newer salaries if one does not already have them
Copy link
Member

@NickAragua NickAragua left a comment

Choose a reason for hiding this comment

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

Nothing major. No need to do anything with the ternary operator comments, they're only there to illustrate a point about relative readability of code to different people.

totalCombatPersonnel++;
} else if (p.hasPrimarySupportRole(false)) {
} else {
Copy link
Member

Choose a reason for hiding this comment

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

This seems to imply that "dependents" and "no role" count as support personnel.

Copy link
Contributor Author

@Windchild292 Windchild292 Apr 22, 2021

Choose a reason for hiding this comment

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

In the vast majority of cases they are. I've not, as per the overall description, finalized the dependent role, but am planning on them being largely considered as support personnel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also consistent with their current implementation in MekHQ.

} else {
return OTHER_RANSOM_VALUES.get(getExperienceLevel(false));
}
return (getPrimaryRole().isMechWarriorGrouping() || getPrimaryRole().isAerospacePilot()
Copy link
Member

Choose a reason for hiding this comment

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

Again, not to be flippant, but do you really think that this ternary operator statement is more readable than the slightly longer but cleaner if/else block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do for now, but will look at this specific example in the near future as I want to make the ransom values customizable.

MekHQ/src/mekhq/gui/CampaignGUI.java Outdated Show resolved Hide resolved
MekHQ/src/mekhq/campaign/personnel/Person.java Outdated Show resolved Hide resolved
@Windchild292 Windchild292 requested a review from NickAragua April 23, 2021 12:42
@Windchild292
Copy link
Contributor Author

Ready for re-review @NickAragua.

@Windchild292 Windchild292 merged commit b0c3bad into MegaMek:master Apr 27, 2021
@Windchild292 Windchild292 deleted the dev_Windchild_PersonnelRoles branch April 27, 2021 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Hydra This will require significant changes across the entire project, likely causing unforeseen bugs. Refactoring (RFE) Enhancement Requests for Enhancement, new features or implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants