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

Acar/on megamek #5643

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
AutoResolveBehaviorSettingsDialog.title=Auto Resolve Help
AutoResolveBehaviorSettingsDialog.autoResolveHelpPath=docs/help/en/AutoResolve.html
AutoResolveBehaviorSettingsDialog.help=Auto Resolve Help
AutoResolveBehaviorSettingsDialog.helpTooltip=Open the Auto Resolve Help documentation in a new window
24 changes: 0 additions & 24 deletions MekHQ/resources/mekhq/resources/AutoResolveMethod.properties

This file was deleted.

21 changes: 20 additions & 1 deletion MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,7 @@ UnitMarketPane.PurchasedUnitBlackMarketSwindled.finances=Purchased %s (lost on b
AutoResolveMethod.dialog.name=Auto Resolve Chance Dialog
AutoResolveMethod.dialog.title=Calculating scenario outcome
AutoResolveMethod.text=Simulating combat...

# Progress gag text
AutoResolveMethod.progress.0=Loading scenario...
AutoResolveMethod.progress.1=Checking mek alignment protocols...
Expand Down Expand Up @@ -1531,4 +1532,22 @@ AutoResolveMethod.progress.95=Simulating AI mutiny risk...
AutoResolveMethod.progress.96=Cross-referencing mek chassis vulnerabilities...
AutoResolveMethod.progress.97=Balancing Lance formations for fairness...
AutoResolveMethod.progress.98=Evaluating retreat probabilities...
AutoResolveMethod.progress.99=Finalizing combat scenario results...
AutoResolveMethod.progress.99=Finalizing combat scenario results...

AutoResolveDialog.title=Auto Resolve Battle
AutoResolveDialog.messageFailedCalc=Commander, we were unable to simulate any combat scenarios. Do you want to proceed?
AutoResolveDialog.messageSimulated=Commander, we ran {0} simulated combat scenarios and our forces came out victorious in {1}, lost {2}, and drew {3} times. This gives us a {4}% chance of victory. Do you want to proceed?
AutoResolveDialog.message.victory=Your forces won the scenario. Did your side control the battlefield at the end of the scenario?
AutoResolveDialog.message.defeat=Your forces lost the scenario. Do you want to declare your side as controlling the battlefield at the end of the scenario?
AutoResolveDialog.victory=Victory!
AutoResolveDialog.defeat=Defeat!
ResolveDialog.control.title=Control of Battlefield?
ResolveDialog.control.message=Did your side control the battlefield at the end of the scenario?


AutoResolveMethod.PRINCESS.text=Princess
AutoResolveMethod.PRINCESS.toolTipText=Princess plays the game for you.
AutoResolveMethod.ABSTRACT_COMBAT.text=Abstract Combat Auto Resolution
AutoResolveMethod.ABSTRACT_COMBAT.toolTipText=ACAR, a fast simulation using a subset of the abstract combat system rules
AutoResolveMethod.promptForAutoResolveMethod.text=Select the method to use for auto resolving the scenario.
AutoResolveMethod.promptForAutoResolveMethod.title=Auto Resolve Method
109 changes: 0 additions & 109 deletions MekHQ/resources/mekhq/resources/acs-report-messages.properties

This file was deleted.

Empty file.
53 changes: 0 additions & 53 deletions MekHQ/resources/mekhq/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,3 @@
# along with MekHQ. If not, see <http://www.gnu.org/licenses/>.
#

acar.invalid_attack=Invalid attack
acar.invalid_skill=Invalid skill
acar.skill=Skill
acar.critical_target_damage=Critical Target Damage
acar.skill_7=Wet behind the ears (skill)
acar.skill_6=Really Green (skill)
acar.skill_5=Green (skill)
acar.skill_4=Regular (skill)
acar.skill_3=Veteran (skill)
acar.skill_2=Elite (skill)
acar.skill_1=Heroic (skill)
acar.skill_0=Legendary (skill)
acar.short_range=Short range
acar.medium_range=Medium range
acar.long_range=Long range
acar.extreme_range=Extreme range
acar.TMM=TMM
acar.attacker_JUMP=Attacker JUMP
acar.target_JUMP=Target JUMP
acar.shaken=Shaken (morale)
acar.unsteady=Unsteady (morale)
acar.broken=Broken (morale)
acar.routed=Routed (morale)
acar.more_than_two_targets=Too many targets
acar.two_targets=Two targets
acar.invalid_engagement_control=Invalid engagement and control
acar.invalid_attacking_formation=Invalid attacking formation
acar.formation_tactics=Tactics
acar.force_engagement=Force engagement
acar.evade=Evade
acar.formation_is_infantry_only=Formation is infantry only
acar.formation_is_vehicle_only=Formation is vehicle only
acar.size_difference=Formation size difference
acar.shaken_morale=Shaken morale
acar.unsteady_morale=Unsteady morale
acar.broken_morale=Broken morale
acar.routed_morale=Routed morale
acar.forced_engagement=Forced Engagement
acar.aerospace_formation=Aerospace Formation
acar.invalid_nerve_recovering=Invalid nerve recovering
acar.formation_morale=Morale
acar.jump_modifier=Movement modifier
acar.withdraw.crippled=Crippled
AutoResolveDialog.title=Auto Resolve Battle
AutoResolveSimulationLogDialog.title=Auto Resolve Report
AutoResolveDialog.messageFailedCalc=Commander, we were unable to simulate any combat scenarios. Do you want to proceed?
AutoResolveDialog.messageSimulated=Commander, we ran {0} simulated combat scenarios and our forces came out victorious in {1}, lost {2}, and drew {3} times. This gives us a {4}% chance of victory. Do you want to proceed?
AutoResolveDialog.message.victory=Your forces won the scenario. Did your side control the battlefield at the end of the scenario?
AutoResolveDialog.message.defeat=Your forces lost the scenario. Do you want to declare your side as controlling the battlefield at the end of the scenario?
AutoResolveDialog.victory=Victory!
AutoResolveDialog.defeat=Defeat!
ResolveDialog.control.title=Control of Battlefield?
ResolveDialog.control.message=Did your side control the battlefield at the end of the scenario?
55 changes: 29 additions & 26 deletions MekHQ/src/mekhq/MekHQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
import megamek.SuiteConstants;
import megamek.client.Client;
import megamek.client.bot.princess.BehaviorSettings;
import megamek.client.ui.dialogs.AutoResolveSimulationLogDialog;
import megamek.client.ui.preferences.PreferencesNode;
import megamek.client.ui.preferences.SuitePreferences;
import megamek.client.ui.swing.GUIPreferences;
import megamek.client.ui.swing.gameConnectionDialogs.ConnectDialog;
import megamek.client.ui.swing.gameConnectionDialogs.HostDialog;
import megamek.client.ui.swing.util.UIUtil;
import megamek.common.Board;
import megamek.common.annotations.Nullable;
import megamek.common.autoresolve.acar.SimulatedClient;
import megamek.common.autoresolve.event.AutoResolveConcludedEvent;
import megamek.common.event.*;
import megamek.common.net.marshalling.SanityInputFilter;
import megamek.logging.MMLogger;
Expand All @@ -43,10 +47,7 @@
import mekhq.campaign.Campaign;
import mekhq.campaign.CampaignController;
import mekhq.campaign.ResolveScenarioTracker;
import mekhq.campaign.autoresolve.Resolver;
import mekhq.campaign.autoresolve.acar.SimulatedClient;
import mekhq.campaign.autoresolve.acar.SimulationOptions;
import mekhq.campaign.autoresolve.event.AutoResolveConcludedEvent;
import mekhq.campaign.autoresolve.AtBSetupForces;
import mekhq.campaign.handler.PostScenarioDialogHandler;
import mekhq.campaign.handler.XPHandler;
import mekhq.campaign.mission.AtBScenario;
Expand All @@ -55,16 +56,14 @@
import mekhq.campaign.stratcon.StratconRulesManager;
import mekhq.campaign.unit.Unit;
import mekhq.gui.CampaignGUI;
import mekhq.gui.dialog.AutoResolveChanceDialog;
import mekhq.gui.dialog.ChooseMulFilesDialog;
import mekhq.gui.dialog.ResolveScenarioWizardDialog;
import mekhq.gui.dialog.helpDialogs.AutoResolveSimulationLogDialog;
import mekhq.gui.panels.StartupScreenPanel;
import mekhq.gui.preferences.StringPreference;
import mekhq.gui.utilities.ObservableString;
import mekhq.service.AutosaveService;
import mekhq.service.IAutosaveService;
import mekhq.utilities.Internationalization;
import mekhq.utilities.MHQInternationalization;

import javax.swing.*;
import javax.swing.text.DefaultEditorKit;
Expand Down Expand Up @@ -535,8 +534,8 @@ public void gameVictory(PostGameResolution gve) {

try {
boolean control = yourSideControlsTheBattlefieldDialogAsk(
Internationalization.getText("ResolveDialog.control.message"),
Internationalization.getText("ResolveDialog.control.title"));
MHQInternationalization.getText("ResolveDialog.control.message"),
MHQInternationalization.getText("ResolveDialog.control.title"));
ResolveScenarioTracker tracker = new ResolveScenarioTracker(currentScenario, getCampaign(), control);
tracker.setClient(gameThread.getClient());
tracker.setEvent(gve);
Expand Down Expand Up @@ -567,8 +566,8 @@ public void resolveScenario(Scenario selectedScenario) {
return;
}
boolean control = yourSideControlsTheBattlefieldDialogAsk(
Internationalization.getText("ResolveDialog.control.message"),
Internationalization.getText("ResolveDialog.control.title"));
MHQInternationalization.getText("ResolveDialog.control.message"),
MHQInternationalization.getText("ResolveDialog.control.title"));

ResolveScenarioTracker tracker = new ResolveScenarioTracker(selectedScenario, getCampaign(), control);

Expand Down Expand Up @@ -643,43 +642,47 @@ public IconPackage getIconPackage() {
*/
public void startAutoResolve(AtBScenario scenario, List<Unit> units) {

this.autosaveService.requestBeforeMissionAutosave(getCampaign());

if (getCampaign().getCampaignOptions().isAutoResolveVictoryChanceEnabled()) {
var proceed = AutoResolveChanceDialog
.showSimulationProgressDialog(
var proceed = megamek.client.ui.dialogs.AutoResolveChanceDialog
.showDialog(
getCampaigngui().getFrame(),
getCampaign().getCampaignOptions().getAutoResolveNumberOfScenarios(),
units,
scenario,
getCampaign()) == JOptionPane.YES_OPTION;
Runtime.getRuntime().availableProcessors(),
getCampaign().getPlayer().getTeam(),
new AtBSetupForces(getCampaign(), units, scenario),
new Board(scenario.getBaseMapX(), scenario.getBaseMapY())) == JOptionPane.YES_OPTION;
if (!proceed) {
return;
}
}

var event = new Resolver(getCampaign(), units, scenario, new SimulationOptions(getCampaign().getGameOptions()))
.resolveSimulation();
var event = megamek.client.ui.dialogs.AutoResolveProgressDialog.showDialog(
getCampaigngui().getFrame(),
new AtBSetupForces(getCampaign(), units, scenario),
new Board(scenario.getBaseMapX(), scenario.getBaseMapY()));

var autoResolveBattleReport = new AutoResolveSimulationLogDialog(getCampaigngui().getFrame(), event.getLogFile());
autoResolveBattleReport.setModal(true);
autoResolveBattleReport.setVisible(true);

autoResolveConcluded(event);
autoResolveConcluded(event, scenario);
}

/**
* This method is called when the auto resolve game is over.
* @param autoResolveConcludedEvent The event that contains the results of the auto resolve game.
*/
public void autoResolveConcluded(AutoResolveConcludedEvent autoResolveConcludedEvent) {
public void autoResolveConcluded(AutoResolveConcludedEvent autoResolveConcludedEvent, AtBScenario scenario) {
try {
String message = autoResolveConcludedEvent.controlledScenario() ?
Internationalization.getText("AutoResolveDialog.message.victory") :
Internationalization.getText("AutoResolveDialog.message.defeat");
MHQInternationalization.getText("AutoResolveDialog.message.victory") :
MHQInternationalization.getText("AutoResolveDialog.message.defeat");
String title = autoResolveConcludedEvent.controlledScenario() ?
Internationalization.getText("AutoResolveDialog.victory") :
Internationalization.getText("AutoResolveDialog.defeat");
MHQInternationalization.getText("AutoResolveDialog.victory") :
MHQInternationalization.getText("AutoResolveDialog.defeat");
boolean control = yourSideControlsTheBattlefieldDialogAsk(message, title);
var scenario = autoResolveConcludedEvent.getScenario();

ResolveScenarioTracker tracker = new ResolveScenarioTracker(scenario, getCampaign(), control);
tracker.setClient(new SimulatedClient(autoResolveConcludedEvent.getGame()));
Expand Down Expand Up @@ -731,7 +734,7 @@ private void initEventHandlers() {
}

private static void setLookAndFeel(String themeName) {
final String theme = themeName.isBlank() ? "com.formdev.flatlaf.FlatDarculaLaf" : themeName;
final String theme = themeName.isBlank() || themeName.equals("UITheme") ? "com.formdev.flatlaf.FlatDarculaLaf" : themeName;

Runnable runnable = () -> {
try {
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/ResolveScenarioTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import megamek.logging.MMLogger;
import mekhq.MekHQ;
import mekhq.Utilities;
import mekhq.campaign.autoresolve.acar.SimulatedClient;
import megamek.common.autoresolve.acar.SimulatedClient;
import mekhq.campaign.event.PersonBattleFinishedEvent;
import mekhq.campaign.finances.Money;
import mekhq.campaign.finances.enums.TransactionType;
Expand Down
Loading
Loading