Class AtBContract
- Direct Known Subclasses:
AtBContract.AtBContractRef
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Represents a reference to another AtBContract. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected megamek.common.icons.Camouflage
protected megamek.client.ui.swing.util.PlayerColour
protected int
protected megamek.common.enums.SkillLevel
protected int
protected int
protected AtBContractType
protected String
protected int
protected String
protected megamek.common.icons.Camouflage
protected String
protected megamek.client.ui.swing.util.PlayerColour
protected String
protected int
protected megamek.common.enums.SkillLevel
protected int
static final double
The minimum intensity below which no scenarios will be generatedprotected AtBMoraleLevel
protected int
protected int
protected AtBContract
protected int
protected int
protected boolean
protected int
protected LocalDate
protected int
protected LocalDate
If the date is non-null, there will be a special scenario or big battle on that date, but the scenario is not generated until the other battle rolls for the week.protected int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AtBContract
(String name) AtBContract
(Contract c, Campaign campaign) -
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptContract
(Campaign campaign) Calculations to be performed once the contract has been accepted.void
Deprecated, for removal: This API element is subject to removal in a future version.- Not in use.void
addEmployerMinorBreaches
(int num) void
addMoraleMod
(int mod) Deprecated, for removal: This API element is subject to removal in a future version.Not in usevoid
void
addPlayerMinorBreaches
(int num) int
calculateContractDifficulty
(int gameYear, boolean useGenericBV, List<megamek.common.Entity> playerCombatUnits) Calculates the difficulty of a contract based on the relative power of enemy forces, player forces, and any allied forces involved in the campaign.int
calculateContractDifficulty
(Campaign campaign) Deprecated.usecalculateContractDifficulty(int, boolean, List)
insteadvoid
calculateLength
(boolean variable) static int
calculateRequiredLances
(Campaign campaign) Calculates the number of lances required for this contract, based on [campaign].void
checkEvents
(Campaign campaign) void
checkMorale
(Campaign campaign, LocalDate today) Checks and updates the morale which depends on various conditions such as the rout end date, skill levels, victories, defeats, etc.void
Applies a salvage override rule for Clan technology based on the contract timeline and faction involvement.boolean
contractExtended
(Campaign campaign) boolean
doBonusRoll
(Campaign campaign, boolean isPostScenario) Performs a bonus roll to determine and execute a random campaign bonus.megamek.common.icons.Camouflage
megamek.client.ui.swing.util.PlayerColour
int
megamek.common.enums.SkillLevel
int
int
getContractDifficultySkulls
(Campaign campaign) This method returns aJPanel
that represents the difficulty skulls for a given mission.int
static int
getEffectiveNumUnits
(Campaign campaign) Calculates the effective number of units available in the given campaign based on unit types and roles.getEmployerName
(int year) getEnemy()
megamek.common.icons.Camouflage
megamek.client.ui.swing.util.PlayerColour
getEnemyName
(int year) Retrieves the name of the enemy for this contract.int
megamek.common.enums.SkillLevel
int
getRandomDayOfMonth
(LocalDate today) int
getRepairLocation
(int unitRating) Retrieves the repair location based on the unit rating and contract type.int
int
int
getScore()
int
Retrieves the percentage of shares for this contract.int
int
void
initContractDetails
(Campaign campaign) boolean
initiateBatchall
(Campaign campaign) This method initiates a batchall, a challenge/dialog to decide on the conduct of a campaign.boolean
boolean
Checks if the Batchall has been accepted for the contract.boolean
static boolean
isMinorPower
(String factionCode) Deprecated, for removal: This API element is subject to removal in a future version.No indicated uses.boolean
void
static megamek.common.icons.Camouflage
pickRandomCamouflage
(int currentYear, String factionCode) Selects a random camouflage for the given faction based on the faction code and year.void
Restores any references to other contracts.void
setAllyBotName
(String name) void
setAllyCamouflage
(megamek.common.icons.Camouflage allyCamouflage) void
setAllyColour
(megamek.client.ui.swing.util.PlayerColour allyColour) void
setAllyQuality
(int allyQuality) void
setAllySkill
(megamek.common.enums.SkillLevel allySkill) void
setAtBSharesPercent
(int pct) void
setAttacker
(boolean isAttacker) void
setBatchallAccepted
(boolean batchallAccepted) Sets thebatchallAccepted
flag for this contract.void
setCommandRoll
(int roll) void
setContractScoreArbitraryModifier
(int newModifier) void
setContractType
(AtBContractType contractType) void
setEmployerCode
(String code, int year) void
setEmployerCode
(String code, LocalDate date) Deprecated.usesetEmployerCode(String, int)
insteadvoid
setEnemyBotName
(String name) void
setEnemyCamouflage
(megamek.common.icons.Camouflage enemyCamouflage) void
setEnemyCode
(String enemyCode) void
setEnemyColour
(megamek.client.ui.swing.util.PlayerColour enemyColour) void
setEnemyQuality
(int enemyQuality) void
setEnemySkill
(megamek.common.enums.SkillLevel enemySkill) void
setMercSubcontract
(boolean sub) void
setMoraleLevel
(AtBMoraleLevel moraleLevel) void
setParentContract
(AtBContract parent) void
setPartsAvailabilityLevel
(int partsAvailabilityLevel) void
setRequiredCombatTeams
(int required) void
setRoutEndDate
(LocalDate routEnd) Sets the end date of the rout.void
setSalvageRoll
(int roll) void
void
setSupportRoll
(int roll) void
setTransportRoll
(int roll) protected int
writeToXMLBegin
(PrintWriter pw, int indent) Methods inherited from class mekhq.campaign.mission.Contract
addSalvageByEmployer, addSalvageByUnit, calculateContract, canSalvage, getAdvanceAmount, getAdvancePct, getBaseAmount, getBattleLossComp, getBattleLossCompString, getCachedJumpPath, getCommandRights, getEmployer, getEndingDate, getEstimatedPayrollExpenses, getEstimatedTotalProfit, getFeeAmount, getJumpPath, getLength, getLengthPlusTravel, getMonthsLeft, getMrbcFeePercentage, getMultiplier, getOverheadAmount, getOverheadComp, getOverheadCompName, getSalvagedByEmployer, getSalvagedByUnit, getSalvagePct, getSalvagePctString, getSigningBonusAmount, getSigningBonusPct, getStartDate, getStraightSupport, getStraightSupportString, getSupportAmount, getTotalAdvanceAmount, getTotalAmount, getTotalAmountPlusFees, getTotalAmountPlusFeesAndBonuses, getTotalEstimatedMaintenanceExpenses, getTotalEstimatedOverheadExpenses, getTotalEstimatedPayrollExpenses, getTotalMonthlyPayOut, getTotalTransportationFees, getTransitAmount, getTransportAmount, getTransportComp, getTransportCompString, getTravelDays, isActiveOn, isSalvageExchange, payMRBCFee, setAdvanceAmount, setAdvancePct, setBaseAmount, setBattleLossComp, setCachedJumpPath, setCommandRights, setEmployer, setEndDate, setFeeAmount, setLength, setMRBCFee, setMultiplier, setOverheadAmount, setOverheadComp, setSalvagedByEmployer, setSalvagedByUnit, setSalvageExchange, setSalvagePct, setSigningBonusAmount, setSigningBonusPct, setStartAndEndDate, setStartDate, setStraightSupport, setSupportAmount, setSystemId, setTransitAmount, setTransportAmount, setTransportComp, subtractSalvageByUnit
Methods inherited from class mekhq.campaign.mission.Mission
addScenario, clearScenarios, generateInstanceFromXML, getCompletedScenarios, getCurrentAtBScenarios, getCurrentScenarios, getDescription, getId, getName, getScenarios, getStatus, getSystem, getSystemId, getSystemName, getType, getVisibleScenarios, hasPendingScenarios, isActiveOn, setDesc, setId, setLegacyPlanetName, setName, setStatus, setType, toString, writeToXML, writeToXMLEnd
-
Field Details
-
MINIMUM_INTENSITY
public static final double MINIMUM_INTENSITYThe minimum intensity below which no scenarios will be generated- See Also:
-
parentContract
-
employerCode
-
enemyCode
-
enemyName
-
contractType
-
allySkill
protected megamek.common.enums.SkillLevel allySkill -
allyQuality
protected int allyQuality -
enemySkill
protected megamek.common.enums.SkillLevel enemySkill -
enemyQuality
protected int enemyQuality -
allyBotName
-
enemyBotName
-
allyCamouflage
protected megamek.common.icons.Camouflage allyCamouflage -
allyColour
protected megamek.client.ui.swing.util.PlayerColour allyColour -
enemyCamouflage
protected megamek.common.icons.Camouflage enemyCamouflage -
enemyColour
protected megamek.client.ui.swing.util.PlayerColour enemyColour -
extensionLength
protected int extensionLength -
requiredCombatTeams
protected int requiredCombatTeams -
moraleLevel
-
routEnd
-
partsAvailabilityLevel
protected int partsAvailabilityLevel -
playerMinorBreaches
protected int playerMinorBreaches -
employerMinorBreaches
protected int employerMinorBreaches -
contractScoreArbitraryModifier
protected int contractScoreArbitraryModifier -
moraleMod
protected int moraleMod -
priorLogisticsFailure
protected boolean priorLogisticsFailure -
specialEventScenarioDate
If the date is non-null, there will be a special scenario or big battle on that date, but the scenario is not generated until the other battle rolls for the week. -
specialEventScenarioType
protected int specialEventScenarioType -
battleTypeMod
protected int battleTypeMod -
nextWeekBattleTypeMod
protected int nextWeekBattleTypeMod
-
-
Constructor Details
-
AtBContract
protected AtBContract() -
AtBContract
-
AtBContract
-
-
Method Details
-
setRoutEndDate
Sets the end date of the rout. This should only be applied on contracts whose morale equals ROUTED- Parameters:
routEnd
- theLocalDate
representing the end date of the rout
-
initContractDetails
-
pickRandomCamouflage
public static megamek.common.icons.Camouflage pickRandomCamouflage(int currentYear, String factionCode) Selects a random camouflage for the given faction based on the faction code and year. If there are no available files in the faction directory, it logs a warning and uses default camouflage.- Parameters:
currentYear
- the current year in the game.factionCode
- the code representing the faction for which the camouflage is to be selected.
-
calculateLength
public void calculateLength(boolean variable) -
calculateRequiredLances
Calculates the number of lances required for this contract, based on [campaign].- Parameters:
campaign
- The campaign to reference.- Returns:
- The number of lances required.
-
getEffectiveNumUnits
Calculates the effective number of units available in the given campaign based on unit types and roles.This method iterates through all combat teams in the specified campaign, ignoring combat teams with the auxiliary role. For each valid combat team, it retrieves the associated force and evaluates all units within that force. The unit contribution to the total is determined based on its type:
- TANK, VTOL, NAVAL, CONV_FIGHTER, AEROSPACEFIGHTER: Adds 1 for non-clan factions, and 0.5 for clan factions.
- PROTOMEK: Adds 0.2 to the total.
- BATTLE_ARMOR, INFANTRY: Adds 0 (excluded from the total).
- Other types: Adds 1 to the total.
Units that aren’t associated with a valid combat team or can’t be fetched due to missing data are ignored. The final result is returned as an integer by flooring the calculated total.
- Parameters:
campaign
- the campaign containing the combat teams and units to evaluate- Returns:
- the effective number of units as an integer
-
isMinorPower
@Deprecated(since="0.50.04", forRemoval=true) public static boolean isMinorPower(String factionCode) Deprecated, for removal: This API element is subject to removal in a future version.No indicated uses.Is not used.- Since:
- 0.50.04
-
checkMorale
Checks and updates the morale which depends on various conditions such as the rout end date, skill levels, victories, defeats, etc. This method also updates the enemy status based on the morale level.- Parameters:
today
- The current date in the context.
-
getRepairLocation
public int getRepairLocation(int unitRating) Retrieves the repair location based on the unit rating and contract type.- Parameters:
unitRating
- The rating of the unit.- Returns:
- The repair location.
-
addMoraleMod
Deprecated, for removal: This API element is subject to removal in a future version.Not in use- Since:
- 0.50.04
-
getScore
public int getScore() -
getContractScoreArbitraryModifier
public int getContractScoreArbitraryModifier() -
doBonusRoll
Performs a bonus roll to determine and execute a random campaign bonus. The roll is simulated using 1d6, and the outcome triggers different bonus effects based on the roll value. The effects may involve recruiting dependents, adding new units, or other benefits as determined by the campaign options and roll outcome.- Parameters:
campaign
- the currentCampaign
instance.isPostScenario
- aboolean
indicating if this roll occurs post-scenario (used to determine specific behaviors for roll = 3).- Returns:
true
if specific post-scenario behavior is triggered (roll = 3), otherwisefalse
.- Throws:
IllegalStateException
- if an unexpected roll value is encountered.
-
isSubcontract
public boolean isSubcontract() -
getParentContract
-
setParentContract
-
isMercSubcontract
public boolean isMercSubcontract() -
setMercSubcontract
public void setMercSubcontract(boolean sub) -
isAttacker
public boolean isAttacker() -
setAttacker
public void setAttacker(boolean isAttacker) -
checkEvents
-
getRandomDayOfMonth
-
contractExtended
-
getMonthlyPayOut
- Overrides:
getMonthlyPayOut
in classContract
-
writeToXMLBegin
- Overrides:
writeToXMLBegin
in classContract
-
loadFieldsFromXmlNode
- Overrides:
loadFieldsFromXmlNode
in classContract
- Throws:
ParseException
-
restore
Restores any references to other contracts.- Parameters:
c
- The Campaign which holds this contract.
-
getEmployerFaction
-
getEmployerCode
-
setEmployerCode
Deprecated.usesetEmployerCode(String, int)
instead- Since:
- 0.50.04
-
setEmployerCode
-
getEmployerName
-
getEnemy
-
getEnemyCode
-
getEnemyName
Retrieves the name of the enemy for this contract.- Parameters:
year
- The current year in the game.- Returns:
- The name of the enemy.
-
setEnemyCode
-
getContractType
-
setContractType
-
getAllySkill
public megamek.common.enums.SkillLevel getAllySkill() -
setAllySkill
public void setAllySkill(megamek.common.enums.SkillLevel allySkill) -
getEnemySkill
public megamek.common.enums.SkillLevel getEnemySkill() -
setEnemySkill
public void setEnemySkill(megamek.common.enums.SkillLevel enemySkill) -
getAllyQuality
public int getAllyQuality() -
setAllyQuality
public void setAllyQuality(int allyQuality) -
getEnemyQuality
public int getEnemyQuality() -
setEnemyQuality
public void setEnemyQuality(int enemyQuality) -
getAllyBotName
-
setAllyBotName
-
getEnemyBotName
-
setEnemyBotName
-
getAllyCamouflage
public megamek.common.icons.Camouflage getAllyCamouflage() -
setAllyCamouflage
public void setAllyCamouflage(megamek.common.icons.Camouflage allyCamouflage) -
getAllyColour
public megamek.client.ui.swing.util.PlayerColour getAllyColour() -
setAllyColour
public void setAllyColour(megamek.client.ui.swing.util.PlayerColour allyColour) -
getEnemyCamouflage
public megamek.common.icons.Camouflage getEnemyCamouflage() -
setEnemyCamouflage
public void setEnemyCamouflage(megamek.common.icons.Camouflage enemyCamouflage) -
getEnemyColour
public megamek.client.ui.swing.util.PlayerColour getEnemyColour() -
setEnemyColour
public void setEnemyColour(megamek.client.ui.swing.util.PlayerColour enemyColour) -
getRequiredCombatTeams
public int getRequiredCombatTeams() -
setRequiredCombatTeams
public void setRequiredCombatTeams(int required) -
getPartsAvailabilityLevel
public int getPartsAvailabilityLevel() -
setPartsAvailabilityLevel
public void setPartsAvailabilityLevel(int partsAvailabilityLevel) -
getMoraleLevel
-
setMoraleLevel
-
isBatchallAccepted
public boolean isBatchallAccepted()Checks if the Batchall has been accepted for the contract.- Returns:
true
if the Batchall has been accepted,false
otherwise.
-
setBatchallAccepted
public void setBatchallAccepted(boolean batchallAccepted) Sets thebatchallAccepted
flag for this contract.- Parameters:
batchallAccepted
- The value to set for thebatchallAccepted
flag.
-
addPlayerMinorBreach
public void addPlayerMinorBreach() -
addPlayerMinorBreaches
public void addPlayerMinorBreaches(int num) -
addEmployerMinorBreach
Deprecated, for removal: This API element is subject to removal in a future version.- Not in use.- Since:
- 0.50.04
-
addEmployerMinorBreaches
public void addEmployerMinorBreaches(int num) -
setContractScoreArbitraryModifier
public void setContractScoreArbitraryModifier(int newModifier) -
getBattleTypeMod
public int getBattleTypeMod() -
getStratconCampaignState
-
setStratconCampaignState
-
acceptContract
Description copied from class:Contract
Calculations to be performed once the contract has been accepted.- Overrides:
acceptContract
in classContract
-
clanTechSalvageOverride
public void clanTechSalvageOverride()Applies a salvage override rule for Clan technology based on the contract timeline and faction involvement. This method checks the factions of both the enemy and employer and determines if a salvage exchange should be forced based on whether the battle occurs before the Battle of Tukayyid.This rule was implemented to better match canon employer behavior during this period.
-
initiateBatchall
This method initiates a batchall, a challenge/dialog to decide on the conduct of a campaign. Prompts the player with a message and options to accept or refuse the batchall.- Parameters:
campaign
- The current campaign.- Returns:
true
if the batchall is accepted,false
otherwise.
-
getContractDifficultySkulls
This method returns aJPanel
that represents the difficulty skulls for a given mission.- Parameters:
campaign
- the campaign for which the difficulty skulls are calculated- Returns:
- a
JPanel
with the difficulty skulls displayed
-
calculateContractDifficulty
Deprecated.usecalculateContractDifficulty(int, boolean, List)
insteadCalculates the difficulty of a contract based on the relative power of enemy forces, player forces, and any allied forces involved in the campaign.The method evaluates the enemy's estimated power against the player's strengths and considers allied contributions depending on the assigned command rights. The result is a difficulty level mapped between 1 and 10, where higher values represent more challenging contracts.
- Parameters:
campaign
- TheCampaign
object representing the current game state. Used to extract information about the player's forces, enemy forces, and allied forces.- Returns:
- An integer representing the difficulty of the contract:
- 1 = very easy
- 10 = extremely difficult
WARNING: Returns `-99` (defined as `ERROR`) if the enemy's power cannot be calculated.
Mapped Result Explanation:
The method divides the absolute percentage difference between enemy and player forces by 20 (rounding up), then adjusts the difficulty accordingly:- If the player's forces are stronger, the difficulty is adjusted downward from a baseline of 5.
- If the enemy's forces are stronger, the difficulty is adjusted upward from a baseline of 5.
- If an error is encountered, the difficulty is returned as -99
- Since:
- 0.50.04
-
calculateContractDifficulty
public int calculateContractDifficulty(int gameYear, boolean useGenericBV, List<megamek.common.Entity> playerCombatUnits) Calculates the difficulty of a contract based on the relative power of enemy forces, player forces, and any allied forces involved in the campaign.The method evaluates the enemy's estimated power against the player's strengths and considers allied contributions depending on the assigned command rights. The result is a difficulty level mapped between 1 and 10, where higher values represent more challenging contracts.
- Parameters:
gameYear
- The current year in the campaign (e.g., fromCampaign.getGameYear()
)useGenericBV
- Whether "Use Generic BV" is enabled in the Campaign OptionsplayerCombatUnits
- List of Entities representing all combat units for the player. This can be obtained viaCampaign.getAllCombatEntities()
.- Returns:
- An integer representing the difficulty of the contract:
- 1 = very easy
- 10 = extremely difficult
WARNING: Returns `-99` (defined as `ERROR`) if the enemy's power cannot be calculated.
Mapped Result Explanation:
The method divides the absolute percentage difference between enemy and player forces by 20 (rounding up), then adjusts the difficulty accordingly:- If the player's forces are stronger, the difficulty is adjusted downward from a baseline of 5.
- If the enemy's forces are stronger, the difficulty is adjusted upward from a baseline of 5.
- If an error is encountered, the difficulty is returned as -99
-
getCommandRoll
public int getCommandRoll()- Returns:
- the command roll that was used to determine command rights. Only used by CamOps Contract Market.
-
setCommandRoll
public void setCommandRoll(int roll) - Parameters:
roll
- the command roll that was used to determine command rights. Only used by CamOps Contract Market.
-
getSalvageRoll
public int getSalvageRoll()- Returns:
- the salvage roll that was used to determine salvage rights. Only used by CamOps Contract Market.
-
setSalvageRoll
public void setSalvageRoll(int roll) - Parameters:
roll
- the salvage roll that was used to determine salvage rights. Only used by CamOps Contract Market.
-
getSupportRoll
public int getSupportRoll()- Returns:
- the support roll that was used to determine support rights. Only used by CamOps Contract Market.
-
setSupportRoll
public void setSupportRoll(int roll) - Parameters:
roll
- the support roll that was used to determine support rights. Only used by CamOps Contract Market.
-
getTransportRoll
public int getTransportRoll()- Returns:
- the transport roll that was used to determine transport rights. Only used by CamOps Contract Market.
-
setTransportRoll
public void setTransportRoll(int roll) - Parameters:
roll
- the transport roll that was used to determine transport rights. Only used by CamOps Contract Market.
-
getRoutedPayout
-