diff --git a/MekHQ/resources/mekhq/resources/Mission.properties b/MekHQ/resources/mekhq/resources/Mission.properties index 6b82d8b25b..b1572c3fc6 100644 --- a/MekHQ/resources/mekhq/resources/Mission.properties +++ b/MekHQ/resources/mekhq/resources/Mission.properties @@ -64,7 +64,7 @@ ContractCommandRights.INTEGRATED.toolTipText=
-+ * If {@code isAllied} is {@code true}, the method calculates the total BV for the allied + * forces inclusive of player forces. If {@code isAllied} is {@code false}, the total BV for + * opposing forces is calculated. + *
+ * The calculation is done based on Bot forces attributed to each side. In the case of
+ * PlanetOwner, the alignment of the owner faction is considered to determine the ownership of
+ * Bot forces.
+ *
+ * @param campaign The campaign in which the forces are participating.
+ * @param isAllied A boolean value indicating whether to calculate the total BV for
+ * allied forces (if true) or opposing forces (if false).
+ * @return The total battle value (BV) either for the allied forces or
+ * opposing forces, as specified by the parameter isAllied.
+ */
+ public int getTeamTotalBattleValue(Campaign campaign, boolean isAllied) {
+ AtBContract contract = getContract(campaign);
+ int totalBattleValue = 0;
+
+ for (BotForce botForce : getBotForces()) {
+ int battleValue = botForce.getTotalBV(campaign);
+
+ int team = botForce.getTeam();
+
+ if (team == PlanetOwner.ordinal()) {
+ String planetOwnerFaction = getPlanetOwnerFaction(contract, campaign.getLocalDate());
+ ForceAlignment forceAlignment = getPlanetOwnerAlignment(contract, planetOwnerFaction, campaign.getLocalDate());
+ team = forceAlignment.ordinal();
+ }
+
+ if (team <= Allied.ordinal()) {
+ if (isAllied) {
+ totalBattleValue += battleValue;
+ }
+ } else if (!isAllied) {
+ totalBattleValue += battleValue;
+ }
+ }
+
+ if (isAllied) {
+ Force playerForces = this.getForces(campaign);
+
+ for (UUID unitID : playerForces.getAllUnits(false)) {
+ try {
+ Unit unit = campaign.getUnit(unitID);
+ Entity entity = unit.getEntity();
+
+ totalBattleValue += entity.calculateBattleValue();
+ } catch (Exception ex) {
+ logger.warn(ex.getMessage(), ex);
+ }
+ }
+ }
+
+ return totalBattleValue;
+ }
}
diff --git a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
index f78e1bf6bd..20f56264b9 100644
--- a/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
+++ b/MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
@@ -3909,7 +3909,7 @@ private static void correctNonAeroFlyerBehavior(List
");
}
+ if (campaign != null) {
+ AtBDynamicScenario backingScenario = getBackingScenario();
+
+ if (backingScenario != null) {
+ stateBuilder.append(String.format("Hostile BV: %d
",
+ backingScenario.getTeamTotalBattleValue(campaign, false)));
+ stateBuilder.append(String.format("Allied BV: %d",
+ backingScenario.getTeamTotalBattleValue(campaign, true)));
+ }
+ }
+
stateBuilder.append("");
return stateBuilder.toString();
}
diff --git a/MekHQ/src/mekhq/gui/StratconPanel.java b/MekHQ/src/mekhq/gui/StratconPanel.java
index 389ca18b62..fc6326052c 100644
--- a/MekHQ/src/mekhq/gui/StratconPanel.java
+++ b/MekHQ/src/mekhq/gui/StratconPanel.java
@@ -18,7 +18,6 @@
import mekhq.MekHQ;
import mekhq.campaign.Campaign;
import mekhq.campaign.force.Force;
-import mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment;
import mekhq.campaign.stratcon.*;
import mekhq.campaign.stratcon.StratconBiomeManifest.ImageType;
import mekhq.gui.stratcon.StratconScenarioWizard;
@@ -40,6 +39,8 @@
import java.util.HashMap;
import java.util.Map;
+import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.Allied;
+
/**
* This panel handles AtB-Stratcon GUI interactions with a specific scenario
* track.
@@ -144,7 +145,7 @@ public void selectTrack(StratconCampaignState campaignState, StratconTrackState
// clear hex selection
boardState.selectedX = null;
boardState.selectedY = null;
- infoArea.setText(buildSelectedHexInfo());
+ infoArea.setText(buildSelectedHexInfo(campaign));
repaint();
}
@@ -471,7 +472,7 @@ private boolean imageLoaded(String imageKey) {
}
private BufferedImage getFacilityImage(StratconFacility facility) {
- String imageKeyPrefix = facility.getOwner() == ForceAlignment.Allied ? StratconBiomeManifest.FACILITY_ALLIED
+ String imageKeyPrefix = facility.getOwner() == Allied ? StratconBiomeManifest.FACILITY_ALLIED
: StratconBiomeManifest.FACILITY_HOSTILE;
String imageKey = imageKeyPrefix + facility.getFacilityType().name();
@@ -569,7 +570,7 @@ private void drawScenarios(Graphics2D g2D) {
if (currentTrack.getFacility(currentCoords) == null) {
drawTextEffect(g2D, scenarioMarker, "Hostile Force Detected", currentCoords);
- } else if (currentTrack.getFacility(currentCoords).getOwner() == ForceAlignment.Allied) {
+ } else if (currentTrack.getFacility(currentCoords).getOwner() == Allied) {
drawTextEffect(g2D, scenarioMarker, "Under Attack!", currentCoords);
}
}
@@ -610,7 +611,7 @@ private void drawFacilities(Graphics2D g2D) {
StratconFacility facility = currentTrack.getFacility(currentCoords);
if ((facility != null) && (facility.isVisible() || trackRevealed || currentTrack.isGmRevealed())) {
- g2D.setColor(facility.getOwner() == ForceAlignment.Allied ? Color.CYAN : Color.RED);
+ g2D.setColor(facility.getOwner() == Allied ? Color.CYAN : Color.RED);
BufferedImage facilityImage = getFacilityImage(facility);
@@ -813,7 +814,7 @@ public void mouseReleasedHandler(MouseEvent e) {
boolean pointFoundOnBoard = detectClickedHex();
if (pointFoundOnBoard) {
- infoArea.setText(buildSelectedHexInfo());
+ infoArea.setText(buildSelectedHexInfo(campaign));
}
repaint();
@@ -850,7 +851,7 @@ public StratconCoords getSelectedCoords() {
* containing info such as whether it's been revealed, assigned forces,
* scenarios, facilities, etc.
*/
- private String buildSelectedHexInfo() {
+ private String buildSelectedHexInfo(Campaign campaign) {
StringBuilder infoBuilder = new StringBuilder();
infoBuilder.append("
");
@@ -864,13 +865,13 @@ private String buildSelectedHexInfo() {
boolean coordsRevealed = currentTrack.hasActiveTrackReveal()
|| currentTrack.getRevealedCoords().contains(boardState.getSelectedCoords());
if (coordsRevealed) {
- infoBuilder.append("Recon complete
");
+ infoBuilder.append("Recon Complete
");
}
if (currentTrack.getAssignedCoordForces().containsKey(boardState.getSelectedCoords())) {
for (int forceID : currentTrack.getAssignedCoordForces().get(boardState.getSelectedCoords())) {
- Force force = campaign.getForce(forceID);
+ Force force = this.campaign.getForce(forceID);
infoBuilder.append(force.getName()).append(" assigned");
if (currentTrack.getStickyForces().contains(forceID)) {
@@ -890,12 +891,12 @@ private String buildSelectedHexInfo() {
if ((facility != null) && (facility.getFacilityType() != null)) {
if (facility.isStrategicObjective()) {
infoBuilder.append(String.format("
Contract objective located",
- facility.getOwner() == ForceAlignment.Allied
+ facility.getOwner() == Allied
? MekHQ.getMHQOptions().getFontColorPositiveHexColor()
: MekHQ.getMHQOptions().getFontColorNegativeHexColor()));
}
infoBuilder.append("")
@@ -912,14 +913,14 @@ private String buildSelectedHexInfo() {
} else {
infoBuilder.append("Recon incomplete");
+ .append("'>Recon Incomplete");
}
infoBuilder.append("
");
StratconScenario selectedScenario = getSelectedScenario();
if ((selectedScenario != null) &&
((selectedScenario.getDeploymentDate() != null) || currentTrack.isGmRevealed())) {
- infoBuilder.append(selectedScenario.getInfo());
+ infoBuilder.append(selectedScenario.getInfo(campaign, true));
}
infoBuilder.append("");
diff --git a/MekHQ/src/mekhq/gui/StratconTab.java b/MekHQ/src/mekhq/gui/StratconTab.java
index 5999cfc3d3..896caa2fba 100644
--- a/MekHQ/src/mekhq/gui/StratconTab.java
+++ b/MekHQ/src/mekhq/gui/StratconTab.java
@@ -13,6 +13,7 @@
*/
package mekhq.gui;
+import megamek.client.ui.swing.util.UIUtil;
import megamek.common.event.Subscribe;
import mekhq.MekHQ;
import mekhq.campaign.event.MissionCompletedEvent;
@@ -48,7 +49,8 @@ public class StratconTab extends CampaignGuiTab {
private StratconPanel stratconPanel;
private JPanel infoPanel;
- private JComboBox