Skip to content

Commit

Permalink
feat: move ACAR base code to MM, needs to implement GUI and force setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Scoppio committed Jan 4, 2025
1 parent b895b8d commit 4ffb3c4
Show file tree
Hide file tree
Showing 88 changed files with 1,828 additions and 1,714 deletions.
Binary file not shown.
115 changes: 115 additions & 0 deletions megamek/i18n/megamek/client/acs-report-messages.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#
# Copyright (c) 2020-2024 - The MegaMek Team. All Rights Reserved.
#
# This file is part of MekHQ.
#
# MekHQ is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MekHQ is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MekHQ. If not, see <http://www.gnu.org/licenses/>.
#
#
# Copyright (c) 2020-2024 - The MegaMek Team. All Rights Reserved.
#
# This file is part of MekHQ.
#
# MekHQ is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MekHQ is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MekHQ. If not, see <http://www.gnu.org/licenses/>.
#
100=<h1>Abstract Combat Auto Resolution</h1>

101=<h2>● Starting Scenario Phase</h2>
102=Team {0} Formations:
103={0} has {1} units.
104={0}, Armor: {1}%, Structure: {2}%, Crew: {3}, Hits: {4}

999=
1000=<h2>○ Initiative Phase for Round {0}</h2>
1005=<h2>○ Initiative Phase for Start of Game Deployment</h2>
1015=▻ {0} has {1} initiative bonus.
1020=▻ The general turn order is:
1040=<h3>※ The turn order is:</h3>
1045=▻ {0}({1}), rolled {2}
1060=<h3>⁜ Future Deployment</h3>
1065=<h4>▶ Round: #{0}</h4>
1066={0} ({1}), Start: {2}
1067={0}[Team {1}]
1200=<hr/>
1230={0}
1231={0} ({1}) {2}
1242=no effect
9999=<h2>● End of the Game</h2>
2020={0} rolls a {1}.

2201=<h2>◔ Engagement and Control Phase</h2>
2200={0} engages {1} under {2} conditions.
2203=needs {0}+ to control engagement.
2202={0} rolled {1}.
2204={0} gains engagement control!
2205={0} fails to gain engagement control.


2002=<h2>◑ Firing Phase</h2>
2001={0} attacks {1}.
3100={0} received {1} damage, {2} armor left
2010=The attack cannot succeed: {0}
2003=Needed {0}+ to hit <i>〈{1}〉</i>.
2012=The attack misses.
2013=The attack hits!
3090=High Stress episode!
3091=It's crippled!
3092=☠ It's destroyed!
3094={0} took {1} damage to its targeting system.
3095=Rolling for internal damage.
3096={0} took {1} damage to its weapons system.
3097=Took no internal damage.

3299=<h2>◕ End Phase</h2>
3298=<h3>Destroyed Units</h3>
3330={0} attempts to withdraw under {1} conditions.
3331=Needs {0}+ to successfully withdraw <i>〈{1}〉</i>.
3332={0} rolled {1} for withdrawal.
3333=The withdrawal is successful!
3334=The withdrawal attempt fails.
3335={0} has has succumbed from his wounds ☠
3336={0} is still alive ({1} hits) ⛑

3337={0} has been devastated, there is nothing left of it.
3338={0} was destroyed by the pilot ejection.
3339={0} was destroyed after being pushed off the combat envelope.
3340={0} was captured by enemy forces.
3341={0} has left the battlefield in full retreat.
3342={0} never joined the battle.
3343={0} was destroyed, it is salvageable.
3344={0} was destroyed by surprise, it is salvageable.

4500={0} attempts a morale check. Need {1} to succeed.
4501={0} rolled {1}.
4502={0} holds steady and does not lose morale.
4503={0} fails its morale check! Morale worsens from {1} to {2}.

5000=<h2>● End of Combat</h2>
5002=Team {0} Report:
5003={0} has {1} units remaining.
5004={0}, Armor remaining: {1}%, Structure remaining: {2}%, Crew: {3}, Hits: {4}
5005={0} - Armor remaining: {1}%, Structure remaining: {2}%
5006={0} has {1} units destroyed.
5007={0} has {1} units retreating.
Empty file.
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4828,3 +4828,5 @@ Bot.commands.caution=Piloting Caution
#### TacOps movement and damage descriptions
TacOps.leaping.leg_damage=leaping (leg damage)
TacOps.leaping.fall_damage=leaping (fall)

####
48 changes: 48 additions & 0 deletions megamek/i18n/megamek/common/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,51 @@ BeastSize.monstrous=Monstrous

ArtilleryMessage.drifted=Artillery drifted here from
BombMessage.drifted=Bomb drifted here from



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

AutoResolveSimulationLogDialog.title=Auto Resolve Report
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public int getPreferredWidth(int col) {
}

public void setData(BoardClassifier bc) {
data = bc.getBoardPaths().values().stream().toList();;
data = bc.getBoardPaths().values().stream().toList();
tags = new ArrayList<>();
width = new ArrayList<>();
height = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package megamek.client.ui.dialogs;

import megamek.client.ui.dialogs.helpDialogs.AbstractHelpDialog;
import megamek.common.internationalization.Internationalization;

import javax.swing.*;
import java.awt.*;
import java.io.File;

public class AutoResolveSimulationLogDialog extends AbstractHelpDialog {

public AutoResolveSimulationLogDialog(final JFrame frame, File logFile) {
super(frame, Internationalization.getText("AutoResolveSimulationLogDialog.title"),
logFile.getAbsolutePath());

setMinimumSize(new Dimension(800, 400));
setModalExclusionType(ModalExclusionType.TOOLKIT_EXCLUDE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private <T> void moveElement(DefaultListModel<T> srcModel, int srcIndex, int trg
private ColourSelectorButton csbBoardTextColor;
private ColourSelectorButton csbBoardSpaceTextColor;
private ColourSelectorButton csbMapsheetColor;
private JSpinner attackArrowTransparency;;
private JSpinner attackArrowTransparency;
private JSpinner ecmTransparency;
private JTextField buttonsPerRow;
private JTextField playersRemainingToShow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo

// Seen by
if (showSeenBy) {
String seenByInfo = getSeenByInfo(game, gameOptions, entity);;
String seenByInfo = getSeenByInfo(game, gameOptions, entity);
if (!seenByInfo.isEmpty()) {
attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString((GUIP.getUnitToolTipHighlightColor())));
seenByInfo = UIUtil.tag("FONT", attr, seenByInfo);
Expand Down
68 changes: 0 additions & 68 deletions megamek/src/megamek/common/autoresolve/AutoResolveMethod.java

This file was deleted.

62 changes: 24 additions & 38 deletions megamek/src/megamek/common/autoresolve/Resolver.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
/*
* Copyright (c) 2024 - The MegaMek Team. All Rights Reserved.
* Copyright (c) 2025 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MekHQ.
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* MekHQ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MekHQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MekHQ. If not, see <http://www.gnu.org/licenses/>.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
package megamek.common.autoresolve;

import megamek.common.Entity;
import megamek.common.Player;
import megamek.common.autoresolve.acar.SimulationContext;
import megamek.common.autoresolve.acar.SimulationManager;
import megamek.common.autoresolve.acar.SimulationOptions;
import megamek.common.autoresolve.acar.phase.*;
import megamek.common.autoresolve.converter.SetupForces;
import megamek.common.autoresolve.event.AutoResolveConcludedEvent;
import megamek.common.options.AbstractOptions;
import mekhq.campaign.Campaign;
import mekhq.campaign.autoresolve.acar.SimulationContext;
import mekhq.campaign.autoresolve.acar.SimulationManager;
import mekhq.campaign.autoresolve.acar.SimulationOptions;
import mekhq.campaign.autoresolve.converter.SetupForces;
import mekhq.campaign.autoresolve.event.AutoResolveConcludedEvent;
import mekhq.campaign.mission.AtBScenario;
import mekhq.campaign.unit.Unit;

import java.util.List;


/**
Expand All @@ -43,20 +30,10 @@ public class Resolver {
private final SimulationOptions options;
private final SetupForces setupForces;

public Resolver(List<Player> playes,
List<Entity> units,
public Resolver(SetupForces setupForces,
AbstractOptions gameOptions) {

this.options = new SimulationOptions(gameOptions);
this.setupForces = new SetupForces(campaign, units, scenario);
}

public AutoResolveConcludedEvent resolveSimulation() {
SimulationContext context = new SimulationContext(scenario, options, setupForces);
SimulationManager simulationManager = new SimulationManager(context);
initializeGameManager(simulationManager);
simulationManager.execute();
return simulationManager.getConclusionEvent();
this.setupForces = setupForces;
}

private void initializeGameManager(SimulationManager simulationManager) {
Expand All @@ -68,4 +45,13 @@ private void initializeGameManager(SimulationManager simulationManager) {
simulationManager.addPhaseHandler(new EndPhase(simulationManager));
simulationManager.addPhaseHandler(new VictoryPhase(simulationManager));
}

public AutoResolveConcludedEvent resolveSimulation() {
SimulationContext context = new SimulationContext(options, setupForces);
SimulationManager simulationManager = new SimulationManager(context);
initializeGameManager(simulationManager);
simulationManager.execute();
return simulationManager.getConclusionEvent();
}

}
Loading

0 comments on commit 4ffb3c4

Please sign in to comment.