Skip to content

Commit bbb9507

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 6fb89c7 + a003a43 commit bbb9507

17 files changed

+559
-299
lines changed

MekHQ/data/forcegenerator/2823.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,7 @@
24012401
</model>
24022402
</chassis>
24032403
<chassis name='J. Edgar Light Hover Tank' unitType='Tank'>
2404-
<availability>CC:4IS:5,Periphery.Deep:5,FS:4,Periphery:5,TC:7,CS:4-,FWL:4,NIOPS:4-,DC:7</availability>
2404+
<availability>CC:4,IS:5,Periphery.Deep:5,FS:4,Periphery:5,TC:7,CS:4-,FWL:4,NIOPS:4-,DC:7</availability>
24052405
<model name=''>
24062406
<availability>General:8,Periphery.Deep:8,Periphery:8</availability>
24072407
</model>

MekHQ/data/forcegenerator/3075.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9557,7 +9557,7 @@
95579557
</model>
95589558
</chassis>
95599559
<chassis name='Leopard' unitType='Dropship'>
9560-
<availability>MOC:8CC:7,HL:7,FRR:7,IS:8,Periphery.Deep:7,WOB:4,FS:7,BAN:2,Periphery:8,CS:4,LA:7,FWL:7,NIOPS:4,DC:7</availability>
9560+
<availability>MOC:8,CC:7,HL:7,FRR:7,IS:8,Periphery.Deep:7,WOB:4,FS:7,BAN:2,Periphery:8,CS:4,LA:7,FWL:7,NIOPS:4,DC:7</availability>
95619561
<model name='&apos;Pocket Warship&apos;'>
95629562
<availability>FWL:3,WOB:6</availability>
95639563
</model>
@@ -10639,7 +10639,7 @@
1063910639
</model>
1064010640
</chassis>
1064110641
<chassis name='Maxim Heavy Hover Transport' unitType='Tank'>
10642-
<availability>CC:2FRR:4,CLAN:2,IS:2,Periphery.Deep:5,WOB:2-,MERC:2,FS:1,CIR:3,Periphery:2,CS:2-,LA:4,NIOPS:2-</availability>
10642+
<availability>CC:2,FRR:4,CLAN:2,IS:2,Periphery.Deep:5,WOB:2-,MERC:2,FS:1,CIR:3,Periphery:2,CS:2-,LA:4,NIOPS:2-</availability>
1064310643
<model name=''>
1064410644
<roles>apc</roles>
1064510645
<availability>HL:2-,IS:4-,Periphery.Deep:8,Periphery:4-</availability>

MekHQ/data/forcegenerator/3085.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4768,7 +4768,7 @@
47684768
</model>
47694769
</chassis>
47704770
<chassis name='Cyrano Gunship' unitType='VTOL'>
4771-
<availability>CC:3,MOC:3,CHH:2-,HL:3,CEI:2,FR:2,MERC:4,CDP:4,RA:2Periphery:4,ROS:6,NIOPS:6,CJF:2-</availability>
4771+
<availability>CC:3,MOC:3,CHH:2-,HL:3,CEI:2,FR:2,MERC:4,CDP:4,RA:2,Periphery:4,ROS:6,NIOPS:6,CJF:2-</availability>
47724772
<model name=''>
47734773
<roles>recon,escort</roles>
47744774
<availability>CC:4,CEI:4,ROS:5</availability>
@@ -11513,7 +11513,7 @@
1151311513
</model>
1151411514
</chassis>
1151511515
<chassis name='Myrmidon Medium Tank' unitType='Tank'>
11516-
<availability>MOC:2CC:5,RA.OA:2,LA:5,ROS:5,FS:5,MERC:5,Periphery:2,DC:4</availability>
11516+
<availability>MOC:2,CC:5,RA.OA:2,LA:5,ROS:5,FS:5,MERC:5,Periphery:2,DC:4</availability>
1151711517
<model name=''>
1151811518
<availability>General:8</availability>
1151911519
</model>

MekHQ/resources/mekhq/resources/AtBStratCon.properties

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ fromChainedScenario.text=Lance already deployed
55
lblDefensiveMinefieldCount.text=Defensive Minefield Count: %d
66
lblSelectIndividualUnits.text=Select individual units (%d max)
77

8-
lblDefensivePostureInstructions.Text=<html>This lance is on a defensive deployment.\
9-
<br>You may deploy additional infantry, battle armor, or minefields.</html>
10-
lblLeadershipInstructions.Text=<html>The force commander's <i>Leadership</i> allows the deployment of additional\
11-
\ auxiliary units - choose from the list below.</html>
12-
lblFCLeadershipAvailable.Text=<html>Force commander's leadership: %d%s%s</html>
13-
lblLeaderUnitsUsed.Text=<br/>%d units already assigned
14-
lblLeadershipReinforcementsUnavailable.Text=<br/>Leadership reinforcements unavailable
8+
lblDefensivePostureInstructions.Text=This lance is on a defensive deployment and you may deploy additional infantry, battle armor, or minefields.
9+
lblLeadershipInstructions.Text=<html>The force commander's leadership allows the deployment of\
10+
\ additional auxiliary units - choose from the list below.\
11+
<br>\
12+
<br><b>Available BV:</b> %s</html
1513
1614
selectForceForTemplate.Text=<html><b>Select a force from the list below.</b>\
1715
<br>\

MekHQ/resources/mekhq/resources/Mission.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ContractCommandRights.INTEGRATED.toolTipText=<html><body style="width: 300px;">-
6464
<br>- No map scouting (StratCon).\
6565
<br>\
6666
<br><i>Integrated command rights, standard for government forces, streamline command and control, particularly in large-scale operations involving multiple forces, ensuring effective collaboration without inter-service rivalry or confusion over command authority.</i></body></html>
67-
ContractCommandRights.INTEGRATED.stratConText=The employer will make Lance assignments. Complete required scenarios to fulfill contract conditions.
67+
ContractCommandRights.INTEGRATED.stratConText=The employer will make Lance assignments.<br>Complete required scenarios to fulfill contract conditions.
6868

6969
ContractCommandRights.HOUSE.text=House
7070
ContractCommandRights.HOUSE.toolTipText=<html><body style="width: 300px;">- Keep your Campaign Victory Points (CVP) positive. Winning a non-initiated scenario: +1 CVP. Losing a non-initiated scenario: -1 CVP.\

MekHQ/src/mekhq/campaign/icons/enums/LayeredForceIconOperationalStatus.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,11 @@ public static LayeredForceIconOperationalStatus determineLayeredForceIconOperati
8888
return NOT_OPERATIONAL;
8989
}
9090

91-
switch (unit.getDamageState()) {
92-
case Entity.DMG_NONE:
93-
return FULLY_OPERATIONAL;
94-
case Entity.DMG_LIGHT:
95-
case Entity.DMG_MODERATE:
96-
return SUBSTANTIALLY_OPERATIONAL;
97-
case Entity.DMG_HEAVY:
98-
case Entity.DMG_CRIPPLED:
99-
return MARGINALLY_OPERATIONAL;
100-
default:
101-
return NOT_OPERATIONAL;
102-
}
91+
return switch (unit.getDamageState()) {
92+
case Entity.DMG_NONE -> FULLY_OPERATIONAL;
93+
case Entity.DMG_LIGHT, Entity.DMG_MODERATE -> SUBSTANTIALLY_OPERATIONAL;
94+
case Entity.DMG_HEAVY, Entity.DMG_CRIPPLED -> MARGINALLY_OPERATIONAL;
95+
default -> NOT_OPERATIONAL;
96+
};
10397
}
10498
}

MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java

+72
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@
2222
import megamek.common.Entity;
2323
import megamek.common.annotations.Nullable;
2424
import megamek.common.enums.SkillLevel;
25+
import megamek.logging.MMLogger;
2526
import mekhq.campaign.Campaign;
27+
import mekhq.campaign.force.Force;
2628
import mekhq.campaign.force.StrategicFormation;
29+
import mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment;
2730
import mekhq.campaign.mission.ScenarioForceTemplate.ForceGenerationMethod;
2831
import mekhq.campaign.mission.atb.AtBScenarioModifier;
2932
import mekhq.campaign.personnel.Person;
3033
import mekhq.campaign.personnel.SkillType;
3134
import mekhq.campaign.rating.IUnitRating;
35+
import mekhq.campaign.unit.Unit;
3236
import mekhq.utilities.MHQXMLUtility;
3337
import org.apache.commons.lang3.StringUtils;
3438
import org.w3c.dom.Element;
@@ -39,6 +43,11 @@
3943
import java.text.ParseException;
4044
import java.util.*;
4145

46+
import static mekhq.campaign.mission.AtBDynamicScenarioFactory.getPlanetOwnerAlignment;
47+
import static mekhq.campaign.mission.AtBDynamicScenarioFactory.getPlanetOwnerFaction;
48+
import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.Allied;
49+
import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.PlanetOwner;
50+
4251
/**
4352
* Data structure intended to hold data relevant to AtB Dynamic Scenarios (AtB 3.0)
4453
* @author NickAragua
@@ -86,6 +95,9 @@ public static class BenchedEntityData {
8695
private transient Map<UUID, ScenarioForceTemplate> playerUnitTemplates;
8796
private transient List<AtBScenarioModifier> scenarioModifiers;
8897

98+
private static final MMLogger logger = MMLogger.create(AtBDynamicScenario.class);
99+
100+
89101
public AtBDynamicScenario() {
90102
super();
91103

@@ -594,4 +606,64 @@ public void clearAllForcesAndPersonnel(Campaign campaign) {
594606
public String getBattlefieldControlDescription() {
595607
return "";
596608
}
609+
610+
/**
611+
* Returns the total battle value (BV) either for allied forces or opposing forces in
612+
* a given contract campaign, as per the parameter {@code isAllied}.
613+
* <p>
614+
* If {@code isAllied} is {@code true}, the method calculates the total BV for the allied
615+
* forces inclusive of player forces. If {@code isAllied} is {@code false}, the total BV for
616+
* opposing forces is calculated.
617+
* <p>
618+
* The calculation is done based on Bot forces attributed to each side. In the case of
619+
* PlanetOwner, the alignment of the owner faction is considered to determine the ownership of
620+
* Bot forces.
621+
*
622+
* @param campaign The campaign in which the forces are participating.
623+
* @param isAllied A boolean value indicating whether to calculate the total BV for
624+
* allied forces (if true) or opposing forces (if false).
625+
* @return The total battle value (BV) either for the allied forces or
626+
* opposing forces, as specified by the parameter isAllied.
627+
*/
628+
public int getTeamTotalBattleValue(Campaign campaign, boolean isAllied) {
629+
AtBContract contract = getContract(campaign);
630+
int totalBattleValue = 0;
631+
632+
for (BotForce botForce : getBotForces()) {
633+
int battleValue = botForce.getTotalBV(campaign);
634+
635+
int team = botForce.getTeam();
636+
637+
if (team == PlanetOwner.ordinal()) {
638+
String planetOwnerFaction = getPlanetOwnerFaction(contract, campaign.getLocalDate());
639+
ForceAlignment forceAlignment = getPlanetOwnerAlignment(contract, planetOwnerFaction, campaign.getLocalDate());
640+
team = forceAlignment.ordinal();
641+
}
642+
643+
if (team <= Allied.ordinal()) {
644+
if (isAllied) {
645+
totalBattleValue += battleValue;
646+
}
647+
} else if (!isAllied) {
648+
totalBattleValue += battleValue;
649+
}
650+
}
651+
652+
if (isAllied) {
653+
Force playerForces = this.getForces(campaign);
654+
655+
for (UUID unitID : playerForces.getAllUnits(false)) {
656+
try {
657+
Unit unit = campaign.getUnit(unitID);
658+
Entity entity = unit.getEntity();
659+
660+
totalBattleValue += entity.calculateBattleValue();
661+
} catch (Exception ex) {
662+
logger.warn(ex.getMessage(), ex);
663+
}
664+
}
665+
}
666+
667+
return totalBattleValue;
668+
}
597669
}

MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -3909,7 +3909,7 @@ private static void correctNonAeroFlyerBehavior(List<Entity> entityList, int boa
39093909
* @param currentDate Current date.
39103910
* @return Faction code.
39113911
*/
3912-
private static String getPlanetOwnerFaction(AtBContract contract, LocalDate currentDate) {
3912+
static String getPlanetOwnerFaction(AtBContract contract, LocalDate currentDate) {
39133913
String factionCode = "MERC";
39143914

39153915
// planet owner is the first of the factions that owns the current planet.
@@ -3935,8 +3935,7 @@ private static String getPlanetOwnerFaction(AtBContract contract, LocalDate curr
39353935
* @param currentDate Current date.
39363936
* @return ForceAlignment.
39373937
*/
3938-
private static ForceAlignment getPlanetOwnerAlignment(AtBContract contract, String factionCode,
3939-
LocalDate currentDate) {
3938+
static ForceAlignment getPlanetOwnerAlignment(AtBContract contract, String factionCode, LocalDate currentDate) {
39403939
// if the faction is one of the planet owners, see if it's either the employer
39413940
// or opfor. If it's not, third-party.
39423941
if (contract.getSystem().getFactions(currentDate).contains(factionCode)) {

MekHQ/src/mekhq/campaign/stratcon/StratconCampaignState.java

+38
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
import jakarta.xml.bind.annotation.XmlElementWrapper;
2727
import jakarta.xml.bind.annotation.XmlRootElement;
2828
import jakarta.xml.bind.annotation.XmlTransient;
29+
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
30+
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
2931
import megamek.logging.MMLogger;
3032
import mekhq.campaign.mission.AtBContract;
3133
import org.w3c.dom.Node;
3234

3335
import javax.xml.namespace.QName;
3436
import java.io.PrintWriter;
37+
import java.time.LocalDate;
3538
import java.util.ArrayList;
3639
import java.util.List;
3740

@@ -63,6 +66,8 @@ public class StratconCampaignState {
6366
@XmlElement(name = "campaignTrack")
6467
private final List<StratconTrackState> tracks;
6568

69+
private List<LocalDate> weeklyScenarios;
70+
6671
@XmlTransient
6772
public AtBContract getContract() {
6873
return contract;
@@ -74,10 +79,12 @@ public void setContract(AtBContract contract) {
7479

7580
public StratconCampaignState() {
7681
tracks = new ArrayList<>();
82+
weeklyScenarios = new ArrayList<>();
7783
}
7884

7985
public StratconCampaignState(AtBContract contract) {
8086
tracks = new ArrayList<>();
87+
weeklyScenarios = new ArrayList<>();
8188
setContract(contract);
8289
}
8390

@@ -102,6 +109,21 @@ public void addTrack(StratconTrackState track) {
102109
tracks.add(track);
103110
}
104111

112+
@XmlJavaTypeAdapter(value = LocalDateAdapter.class)
113+
@XmlElementWrapper(name = "weeklyScenarios")
114+
@XmlElement(name = "weeklyScenario")
115+
public List<LocalDate> getWeeklyScenarios() {
116+
return weeklyScenarios;
117+
}
118+
119+
public void addWeeklyScenario(LocalDate weeklyScenario) {
120+
weeklyScenarios.add(weeklyScenario);
121+
}
122+
123+
public void setWeeklyScenarios(final List<LocalDate> weeklyScenarios) {
124+
this.weeklyScenarios = weeklyScenarios;
125+
}
126+
105127
public int getSupportPoints() {
106128
return supportPoints;
107129
}
@@ -232,4 +254,20 @@ public static StratconCampaignState Deserialize(Node xmlNode) {
232254

233255
return resultingCampaignState;
234256
}
257+
258+
/**
259+
* This adapter provides a way to convert between a LocalDate and the ISO-8601 string
260+
* representation of the date that is used for XML marshaling and unmarshalling in JAXB.
261+
*/
262+
public static class LocalDateAdapter extends XmlAdapter<String, LocalDate> {
263+
@Override
264+
public String marshal(LocalDate date) {
265+
return date.toString();
266+
}
267+
268+
@Override
269+
public LocalDate unmarshal(String date) throws Exception {
270+
return LocalDate.parse(date);
271+
}
272+
}
235273
}

0 commit comments

Comments
 (0)