diff --git a/MekHQ/src/mekhq/campaign/mission/AtBContract.java b/MekHQ/src/mekhq/campaign/mission/AtBContract.java index 12b7036503..12dd3babbc 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBContract.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBContract.java @@ -375,6 +375,16 @@ public void calculateLength(final boolean variable) { setLength(getContractType().calculateLength(variable, this)); } + /** + * Calculates the number of lances required for this contract, based on [campaign]. + * + * @param campaign The campaign to reference. + * @return The number of lances required. + */ + public static int calculateRequiredLances(Campaign campaign) { + return Math.max(getEffectiveNumUnits(campaign) / 6, 1); + } + public static int getEffectiveNumUnits(Campaign campaign) { double numUnits = 0; for (UUID uuid : campaign.getForces().getAllUnits(true)) { @@ -1477,7 +1487,7 @@ public AtBContract(Contract c, Campaign campaign) { enemyCode = "REB"; } - requiredLances = Math.max(getEffectiveNumUnits(campaign) / 6, 1); + requiredLances = calculateRequiredLances(campaign); setPartsAvailabilityLevel(getContractType().calculatePartsAvailabilityLevel()); diff --git a/MekHQ/src/mekhq/gui/dialog/NewAtBContractDialog.java b/MekHQ/src/mekhq/gui/dialog/NewAtBContractDialog.java index 98e8cfaa87..7590900e68 100644 --- a/MekHQ/src/mekhq/gui/dialog/NewAtBContractDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/NewAtBContractDialog.java @@ -527,6 +527,8 @@ protected void btnOKActionPerformed(ActionEvent evt) { contract.setDesc(txtDesc.getText()); contract.setCommandRights(choiceCommand.getSelectedItem()); + contract.setRequiredLances(AtBContract.calculateRequiredLances(campaign)); + contract.setEnemyCode(getCurrentEnemyCode()); contract.setAllySkill(comboAllySkill.getSelectedItem()); contract.setAllyQuality(cbAllyQuality.getSelectedIndex());