Skip to content

Commit

Permalink
Merge pull request #2646 from NickAragua/small_unit_contract_init_fix
Browse files Browse the repository at this point in the history
Small unit contract init fix
  • Loading branch information
NickAragua authored May 29, 2021
2 parents 6f37421 + 22f309b commit 4c2b9e7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion MekHQ/data/scenariotemplates/Convoy Escort.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<name>Convoy Escort</name>
<shortBriefing>Protect an allied supply convoy.</shortBriefing>
<detailedBriefing>Escort the allied convoy across the map or rout the attacking force.</detailedBriefing>
<isHostileFacility>false</isHostileFacility>
<isAlliedFacility>false</isAlliedFacility>
<mapParameters>
<allowedTerrainTypes/>
<allowRotation>false</allowRotation>
Expand Down Expand Up @@ -36,6 +38,7 @@
<generationOrder>1</generationOrder>
<maxWeightClass>4</maxWeightClass>
<minWeightClass>0</minWeightClass>
<objectiveLinkedForces/>
<retreatThreshold>50</retreatThreshold>
<startingAltitude>0</startingAltitude>
<syncDeploymentType>SameEdge</syncDeploymentType>
Expand Down Expand Up @@ -65,6 +68,7 @@
<generationOrder>5</generationOrder>
<maxWeightClass>4</maxWeightClass>
<minWeightClass>1</minWeightClass>
<objectiveLinkedForces/>
<retreatThreshold>50</retreatThreshold>
<startingAltitude>0</startingAltitude>
<syncDeploymentType>OppositeEdge</syncDeploymentType>
Expand Down Expand Up @@ -99,6 +103,7 @@
<generationOrder>4</generationOrder>
<maxWeightClass>4</maxWeightClass>
<minWeightClass>1</minWeightClass>
<objectiveLinkedForces/>
<retreatThreshold>50</retreatThreshold>
<startingAltitude>0</startingAltitude>
<syncDeploymentType>None</syncDeploymentType>
Expand All @@ -108,7 +113,9 @@
</scenarioForces>
<scenarioObjectives>
<scenarioObjective>
<associatedForceNames/>
<associatedForceNames>
<associatedForceName>Convoy</associatedForceName>
</associatedForceNames>
<associatedUnitIDs/>
<successEffects>
<successEffect>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static void initializeCampaignState(AtBContract contract, Campaign campai
for (ObjectiveParameters objectiveParams : contractDefinition.getObjectiveParameters()) {
int objectiveCount = objectiveParams.objectiveCount > 0 ?
(int) objectiveParams.objectiveCount :
(int) (-objectiveParams.objectiveCount * contract.getRequiredLances());
(int) Math.max(1, -objectiveParams.objectiveCount * contract.getRequiredLances());

List<Integer> trackObjects = trackObjectDistribution(objectiveCount, campaignState.getTracks().size());

Expand Down
4 changes: 2 additions & 2 deletions MekHQ/src/mekhq/gui/StratconTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private String buildShortStrategicObjectiveText(StratconCampaignState campaignSt
}

// special logic for non-independent command clauses
if (campaignState.getContract().getCommandRights() <= Contract.COM_LIAISON) {
if (!campaignState.getContract().getCommandRights().isIndependent()) {
desiredObjectives++;

if (campaignState.getVictoryPoints() > 0) {
Expand Down Expand Up @@ -345,7 +345,7 @@ private String buildStrategicObjectiveText(StratconCampaignState campaignState)
}

// special case text reminding player to complete required scenarios
if (campaignState.getContract().getCommandRights() <= Contract.COM_LIAISON) {
if (!campaignState.getContract().getCommandRights().isIndependent()) {
if (campaignState.getVictoryPoints() > 0) {
sb.append("<span color='green'>");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import mekhq.campaign.force.Force;
import mekhq.campaign.mission.AtBContract;
import mekhq.campaign.mission.Contract;
import mekhq.campaign.mission.enums.ContractCommandRights;
import mekhq.campaign.mission.enums.MissionStatus;
import mekhq.campaign.personnel.Person;
import mekhq.campaign.personnel.enums.PersonnelRole;
Expand Down Expand Up @@ -165,6 +166,7 @@ public void generateContractOffersMercSubcontractTest() {
when(existing.getStartDate()).thenReturn(campaign.getLocalDate().minusDays(3000));
when(existing.getEndingDate()).thenReturn(campaign.getLocalDate().plusDays(3000));
when(existing.isActiveOn(campaign.getLocalDate(), false)).thenCallRealMethod();
when(existing.getCommandRights()).thenReturn(ContractCommandRights.INDEPENDENT);
campaign.importMission(existing);

ContractMarket market = new ContractMarket();
Expand Down

0 comments on commit 4c2b9e7

Please sign in to comment.