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 Contract Automation #5172

Merged
merged 7 commits into from
Nov 7, 2024
Merged

Conversation

IllianiCBT
Copy link
Collaborator

Currently accepting a contract is a bit of a process: you need to accept the contract, navigate to the Briefing Room, click on the system, click on Calculate Jump Path, click on Begin Transit. Then, by the time you arrive half of your forces are falling apart from failed maintenance checks.

To resolve that last problem, I'm aware that many of our players advise mothballing forces before transit. Seeing just how crippling RAW maintenance rules can be, I'm inclined to agree.

From a New Player Experience perspective, both of these issues present a couple of problems:

  • Having beginning a contract such a process creates multiple 'quit moments' for the player, multiple stumbling blocks where if they can't figure out what they want to do they're potentially just going to close the program.
  • Players don't expect to arrive with half of their 'Meks falling apart. From what I've seen, this usually results in the player just GM fixing the units, or turning off maintenance entirely.
  • Mothballing units means the player has to remember to unmothball them when they arrive. If they forget, they're likely to just GM Active.

This PR attempts to resolve these options in a couple of steps:

  • When the contract is accepted the player is presented with a dialog asking whether they would like to mothball their TO&E for transport. This mothballing is automatic, to avoid any issues with Tech assignment. We're essentially GM Mothballing, and this can be justified as the employer hiring techs or as techs to ensure their contracted unit is able to get en route as quickly as possible.
  • A second dialog is then triggered, asking the player whether they would like to begin transit to the contract system. If they accept a route is immediately laid out and transit begins.
  • When the contract date arrives all of the players units, previously mothballed by this system, are automatically un-mothballed.

Implemented automated prompts for contract initiation, including mothballing units, charting courses, and beginning transit. Added the ability to track and manage automatically mothballed units within the campaign.
Removed the "(GM)" designation from mothball and activation reports to streamline notification messages. Enhanced contract automation with automated unit activation upon entering the target system and improved dialogue prompts for transit operations.
Added "The MegaMek Team" copyright for 2024 to Unit.java, Contract.java, and ContractMarketDialog.java. This update ensures proper attribution and legal compliance for the project's source files.
Added functionality to handle automated mothballing of units in Campaign.java, including saving and loading from XML. Enhanced ContractAutomation dialog by refining employer name handling and transitioning to a JDialog. Verbose strings in properties files modified for better clarity.
@IllianiCBT IllianiCBT added the UX User experience label Nov 5, 2024
@IllianiCBT IllianiCBT self-assigned this Nov 5, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.51%. Comparing base (2b3d042) to head (dfef5ae).
Report is 35 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5172      +/-   ##
============================================
- Coverage     10.52%   10.51%   -0.02%     
+ Complexity     6042     6040       -2     
============================================
  Files           956      957       +1     
  Lines        134346   134513     +167     
  Branches      19514    19544      +30     
============================================
- Hits          14145    14141       -4     
- Misses       118851   119018     +167     
- Partials       1350     1354       +4     

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

@WeaverThree
Copy link
Collaborator

I've always just run with x4 maint time and it hasn't been a problem during transit, buuuut I'm also using 'only break on A quality' and I don't know if I'm running with the default maintenence values.

One thing I can't tell from glancing at the code, is does this mothball units currently under refit?

Right now, I just checked, you can start a refit and then mothball a unit, and the refit will proceed. But you cannot refit a unit that is already mothballed. Does this need to change?

@IllianiCBT
Copy link
Collaborator Author

My gut tells me we probably shouldn't allow refits on mothball units at all, and we should probably prevent the mothballing of units undergoing refit.

Replaced the check for unit mothball status with a more comprehensive condition that includes availability and repair status. This ensures only appropriate units are added to the mothball targets list.
The outdated comments regarding SpecialAbility and error handling in processAutomatedMothballNodes were removed. This cleanup improves code readability and maintains the focus on current logic.
@IllianiCBT
Copy link
Collaborator Author

Updated to check unit is both available (is present, not deployed, not refitting, not mothballing, and not mothballed) and not under repairs.

Copy link
Collaborator

@rjhancock rjhancock left a comment

Choose a reason for hiding this comment

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

Just did a quick code review.

@IllianiCBT
Copy link
Collaborator Author

I appreciate you.

Copy link
Member

@SJuliez SJuliez left a comment

Choose a reason for hiding this comment

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

Great idea this!

mothballedUnits.add(unit);
}

return mothballedUnits;
Copy link
Member

Choose a reason for hiding this comment

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

might simply return mothballTargets (?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point well made

* @param campaign The current campaign
* @return The title of the commander, or a default string if no commander.
*/
private static String getCommanderAddress(Campaign campaign) {
Copy link
Member

Choose a reason for hiding this comment

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

It feels like this can't be the first time this is done (or it might not be the last)... same for the speaker icon. But I wouldnt know. There is this "this contract is too difficult for your wimpy forces" dialog. Might be something to unify in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, moved it to Campaign.java

mainPanel.add(descriptionPanel, BorderLayout.CENTER);

// Create JOptionPane
JOptionPane optionPane = new JOptionPane(mainPanel,
Copy link
Member

Choose a reason for hiding this comment

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

you are probably double-dialoging this because JOptionPane is not flexible, right?

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 the intent, but on a second viewing I don't think it's necessary and double-dialoging isn't doing anything beneficial here, just unnecessarily increasing complexity.

Removed.

public static void performAutomatedActivation(Campaign campaign) {
List<Unit> units = campaign.getAutomatedMothballUnits();

if (units.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

it feels like this is unnecessary, the loop will simply skip if campaign.getAutomatedMothballUnits() is empty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was a relic from an earlier iteration and should have been removed. Thanks for pointing it out.

activateUnitAction.execute(campaign, unit);
MekHQ.triggerEvent(new UnitChangedEvent(unit));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

should this method clean up the automothball list? If getAutomatedMothballUnits() is not a copy and is modifiable:
units.removeIf(unit -> !unit.isMothballed());

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for mentioning this, that was an oversight

Extracted commander address logic into `Campaign` class. Enhanced UI components for contract automation dialogs and added detailed mothballing and activation reporting.
@IllianiCBT
Copy link
Collaborator Author

Updated to incorporate suggestions from Julie

@IllianiCBT IllianiCBT merged commit f0ee9fd into MegaMek:master Nov 7, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX User experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants