Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/MegaMek/mekhq
Browse files Browse the repository at this point in the history
  • Loading branch information
Windchild292 committed May 24, 2022
2 parents af18afe + ae630c9 commit 08aa9c7
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions MekHQ/data/scenariotemplates/Assassinate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<minWeightClass>1</minWeightClass>
<retreatThreshold>50</retreatThreshold>
<startingAltitude>0</startingAltitude>
<subjectToRandomRemoval>false</subjectToRandomRemoval>
<syncDeploymentType>OppositeEdge</syncDeploymentType>
<syncedForceName>Player</syncedForceName>
<useArtillery>false</useArtillery>
Expand Down
1 change: 1 addition & 0 deletions MekHQ/data/scenariotemplates/Capture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<minWeightClass>1</minWeightClass>
<retreatThreshold>50</retreatThreshold>
<startingAltitude>0</startingAltitude>
<subjectToRandomRemoval>false</subjectToRandomRemoval>
<syncDeploymentType>OppositeEdge</syncDeploymentType>
<syncedForceName>Player</syncedForceName>
<useArtillery>false</useArtillery>
Expand Down
1 change: 1 addition & 0 deletions MekHQ/data/scenariotemplates/Convoy Attack.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<maxWeightClass>4</maxWeightClass>
<minWeightClass>1</minWeightClass>
<retreatThreshold>50</retreatThreshold>
<subjectToRandomRemoval>false</subjectToRandomRemoval>
<startingAltitude>0</startingAltitude>
<syncDeploymentType>None</syncDeploymentType>
<useArtillery>false</useArtillery>
Expand Down
1 change: 1 addition & 0 deletions MekHQ/data/scenariotemplates/Destroy Grounded Dropship.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<objectiveLinkedForces/>
<retreatThreshold>50</retreatThreshold>
<startingAltitude>0</startingAltitude>
<subjectToRandomRemoval>false</subjectToRandomRemoval>
<syncDeploymentType>None</syncDeploymentType>
<useArtillery>false</useArtillery>
</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<objectiveLinkedForces/>
<retreatThreshold>50</retreatThreshold>
<startingAltitude>5</startingAltitude>
<subjectToRandomRemoval>false</subjectToRandomRemoval>
<syncDeploymentType>OppositeEdge</syncDeploymentType>
<syncedForceName>Player</syncedForceName>
<useArtillery>false</useArtillery>
Expand Down
1 change: 1 addition & 0 deletions MekHQ/data/scenariotemplates/Space - Blockade Run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<objectiveLinkedForces/>
<retreatThreshold>50</retreatThreshold>
<startingAltitude>0</startingAltitude>
<subjectToRandomRemoval>false</subjectToRandomRemoval>
<syncDeploymentType>SameEdge</syncDeploymentType>
<syncedForceName>Player</syncedForceName>
<useArtillery>false</useArtillery>
Expand Down
2 changes: 2 additions & 0 deletions MekHQ/docs/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ VERSION HISTORY:
+ PR #3106: Financial Terms: Fixing / Expanding Asset Terms, Fixing Loan Term Date Calculations, Adding Semiannual Term
+ Issue #3281: Preventing Contract Market No Selected Contract NPE
+ PR #3292: Prevent StratCon from generating scenarios on the strategic map when enemy morale is "rout".
+ Issue #3294: Unit Is Properly Removed after Black Market Swindle
+ Issue #3160: Stratcon - Prevent "Good Intel" modifier from removing units that are scenario objectives
+ Updating to JAXB 4.0.0 from 2.3.2
+ Updating to Launch4j 2.5.3 from 2.5.1
+ Updating to Apache Commons CSV 1.9.0 from 1.8
Expand Down
14 changes: 14 additions & 0 deletions MekHQ/src/mekhq/campaign/mission/ScenarioForceTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ public enum SynchronizedDeploymentType {
*/
private List<String> objectiveLinkedForces;

/**
* Whether or not this force is subject to modifiers that cause random unit removal
* e.g. "Good Intel".
*/
private boolean subjectToRandomRemoval = true;

@Override
public ScenarioForceTemplate clone() {
return new ScenarioForceTemplate(this);
Expand Down Expand Up @@ -607,6 +613,14 @@ public void setStartingAltitude(int startingAltitude) {
public void setDeployOffboard(boolean deployOffBoard) {
this.deployOffBoard = deployOffBoard;
}

public boolean isSubjectToRandomRemoval() {
return subjectToRandomRemoval;
}

public void setSubjectToRandomRemoval(boolean subjectToRandomRemoval) {
this.subjectToRandomRemoval = subjectToRandomRemoval;
}

@XmlElementWrapper(name = "objectiveLinkedForces")
@XmlElement(name = "objectiveLinkedForce")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ public static void removeUnits(AtBDynamicScenario scenario, Campaign campaign, F
for (int x = 0; x < actualUnitsToRemove; x++) {
int botForceIndex = Compute.randomInt(scenario.getNumBots());
BotForce bf = scenario.getBotForce(botForceIndex);
ScenarioForceTemplate template = scenario.getBotForceTemplates().get(bf);
boolean subjectToRemoval = (template != null) && template.isSubjectToRandomRemoval();

// only remove units from a bot force if it's on the affected team
// AND if it has any units to remove
if ((bf.getTeam() == ScenarioForceTemplate.TEAM_IDS.get(eventRecipient.ordinal()))
&& !bf.getFullEntityList(campaign).isEmpty()) {
&& !bf.getFullEntityList(campaign).isEmpty() && subjectToRemoval) {
int unitIndexToRemove = Compute.randomInt(bf.getFullEntityList(campaign).size());
bf.removeEntity(unitIndexToRemove);
}
Expand Down
2 changes: 2 additions & 0 deletions MekHQ/src/mekhq/gui/panes/UnitMarketPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public void purchaseSelectedOffers() {
final Entity entity = offer.getEntity();
if (entity == null) {
LogManager.getLogger().error("Cannot purchase a null entity");
getCampaign().getUnitMarket().getOffers().remove(offer);
offersIterator.remove();
continue;
}
Expand All @@ -429,6 +430,7 @@ public void purchaseSelectedOffers() {
price.dividedBy(roll), String.format(resources.getString("UnitMarketPane.PurchasedUnitBlackMarketSwindled.finances"),
entity.getShortName()));
getCampaign().addReport(resources.getString("UnitMarketPane.BlackMarketSwindled.report"));
getCampaign().getUnitMarket().getOffers().remove(offer);
offersIterator.remove();
continue;
}
Expand Down
4 changes: 1 addition & 3 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,11 @@ Log4j2 (Logging) : 2.17.2 [![Maven Central](https://img.shields.io/maven-central

JUnit Jupiter (Unit Testing) : 5.8.2 [![Maven Central](https://img.shields.io/maven-central/v/org.junit.jupiter/junit-jupiter.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.junit.jupiter%22%20AND%20a:%22junit-jupiter%22) : https://junit.org/junit5/

JUnit Vintage (Unit Testing) : 5.8.2 [![Maven Central](https://img.shields.io/maven-central/v/org.junit.vintage/junit-vintage-engine.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.junit.vintage%22%20AND%20a:%22junit-vintage-engine%22) : https://junit.org/junit5/

Mockito (Unit Testing) : 4.5.1 [![Maven Central](https://img.shields.io/maven-central/v/org.mockito/mockito-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.mockito%22%20AND%20a:%22mockito-core%22) : https://site.mockito.org/

### 6.4. MegaMek Dependencies
Jackson (Jackson JSON) (JSON setup used for the internal graphical preference setup)
: 2.13.2 [![Jackson](https://img.shields.io/maven-central/v/com.fasterxml.jackson.core/jackson-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.fasterxml.jackson.core%22%20AND%20a:%22jackson-core%22) : https://github.com/FasterXML/jackson-core
: 2.13.3 [![Jackson](https://img.shields.io/maven-central/v/com.fasterxml.jackson.core/jackson-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.fasterxml.jackson.core%22%20AND%20a:%22jackson-core%22) : https://github.com/FasterXML/jackson-core

Flat Look and Feel (FlatLaf) (Expanded Themes, including Dark Mode) : 2.2 [![Maven Central](https://img.shields.io/maven-central/v/com.formdev/flatlaf.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.formdev%22%20AND%20a:%22flatlaf%22) : https://github.com/JFormDesigner/FlatLaf

Expand Down

0 comments on commit 08aa9c7

Please sign in to comment.