Skip to content

Commit

Permalink
Merge pull request #3951 from IllianiCBT/AtB_ObjectiveTVP
Browse files Browse the repository at this point in the history
Variable OperationalVP Added to CommonObjectiveFactory.java
  • Loading branch information
Sleet01 authored Apr 3, 2024
2 parents 8fa537d + f7e873e commit 52874d9
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 71 deletions.
34 changes: 17 additions & 17 deletions MekHQ/src/mekhq/campaign/mission/CommonObjectiveFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static ScenarioObjective getKeepAttachedGroundUnitsAlive(AtBContract cont
/**
* Generates a "keep at least X% or X of [force] units" objective from the bot force with the specified name
*/
public static ScenarioObjective getPreserveSpecificFriendlies(String forceName, int number, boolean fixedAmount) {
public static ScenarioObjective getPreserveSpecificFriendlies(String forceName, int OperationalVP, int number, boolean fixedAmount) {
ScenarioObjective keepFriendliesAlive = new ScenarioObjective();
if (fixedAmount) {
keepFriendliesAlive.setDescription(String.format(resourceMap.getString("commonObjectives.preserveFriendlyUnits.text"), number, ""));
Expand All @@ -85,12 +85,12 @@ public static ScenarioObjective getPreserveSpecificFriendlies(String forceName,

ObjectiveEffect successEffect = new ObjectiveEffect();
successEffect.effectType = ObjectiveEffectType.ScenarioVictory;
successEffect.howMuch = 1;
successEffect.howMuch = OperationalVP;
keepFriendliesAlive.addSuccessEffect(successEffect);

ObjectiveEffect friendlyFailureEffect = new ObjectiveEffect();
friendlyFailureEffect.effectType = ObjectiveEffectType.ScenarioDefeat;
friendlyFailureEffect.howMuch = 1;
friendlyFailureEffect.howMuch = OperationalVP;
keepFriendliesAlive.addFailureEffect(friendlyFailureEffect);

return keepFriendliesAlive;
Expand All @@ -101,7 +101,7 @@ public static ScenarioObjective getPreserveSpecificFriendlies(String forceName,
* as well as any attached allies, alive
*/
public static ScenarioObjective getKeepFriendliesAlive(Campaign campaign, AtBContract contract,
AtBScenario scenario, int number,
AtBScenario scenario, int OperationalVP, int number,
boolean fixedAmount) {
ScenarioObjective keepFriendliesAlive = new ScenarioObjective();
if (fixedAmount) {
Expand All @@ -119,12 +119,12 @@ public static ScenarioObjective getKeepFriendliesAlive(Campaign campaign, AtBCon

ObjectiveEffect successEffect = new ObjectiveEffect();
successEffect.effectType = ObjectiveEffectType.ScenarioVictory;
successEffect.howMuch = 1;
successEffect.howMuch = OperationalVP;
keepFriendliesAlive.addSuccessEffect(successEffect);

ObjectiveEffect friendlyFailureEffect = new ObjectiveEffect();
friendlyFailureEffect.effectType = ObjectiveEffectType.ScenarioDefeat;
friendlyFailureEffect.howMuch = 1;
friendlyFailureEffect.howMuch = OperationalVP;
keepFriendliesAlive.addFailureEffect(friendlyFailureEffect);

return keepFriendliesAlive;
Expand All @@ -134,7 +134,7 @@ public static ScenarioObjective getKeepFriendliesAlive(Campaign campaign, AtBCon
* Generates a "destroy x% of all units" from the given force name objective
* @param forcename Explicit enemy force name
*/
public static ScenarioObjective getDestroyEnemies(String forcename, int percentage) {
public static ScenarioObjective getDestroyEnemies(String forcename, int OperationalVP, int percentage) {
ScenarioObjective destroyHostiles = new ScenarioObjective();
destroyHostiles.setDescription(String.format(resourceMap.getString("commonObjectives.forceWithdraw.text"), percentage));
destroyHostiles.setObjectiveCriterion(ObjectiveCriterion.ForceWithdraw);
Expand All @@ -143,12 +143,12 @@ public static ScenarioObjective getDestroyEnemies(String forcename, int percenta

ObjectiveEffect successEffect = new ObjectiveEffect();
successEffect.effectType = ObjectiveEffectType.ScenarioVictory;
successEffect.howMuch = 1;
successEffect.howMuch = OperationalVP;
destroyHostiles.addSuccessEffect(successEffect);

ObjectiveEffect failureEffect = new ObjectiveEffect();
failureEffect.effectType = ObjectiveEffectType.ScenarioDefeat;
failureEffect.howMuch = 1;
failureEffect.howMuch = OperationalVP;
destroyHostiles.addFailureEffect(failureEffect);

return destroyHostiles;
Expand All @@ -158,14 +158,14 @@ public static ScenarioObjective getDestroyEnemies(String forcename, int percenta
* Generates a "destroy x% of all units" objective from the primary opposing force
* @param contract Contract to examine for enemy force name.
*/
public static ScenarioObjective getDestroyEnemies(AtBContract contract, int percentage) {
return getDestroyEnemies(contract.getEnemyBotName(), percentage);
public static ScenarioObjective getDestroyEnemies(AtBContract contract, int OperationalVP, int percentage) {
return getDestroyEnemies(contract.getEnemyBotName(), OperationalVP, percentage);
}

/**
* Generates a "prevent x% of all units from reaching given edge" objective from the primary opposing force
*/
public static ScenarioObjective getPreventEnemyBreakthrough(AtBContract contract, int percentage, OffBoardDirection direction) {
public static ScenarioObjective getPreventEnemyBreakthrough(AtBContract contract, int OperationalVP, int percentage, OffBoardDirection direction) {
ScenarioObjective destroyHostiles = new ScenarioObjective();
destroyHostiles.setDescription(
String.format(resourceMap.getString("commonObjectives.preventBreakthrough.text"), percentage, direction));
Expand All @@ -176,12 +176,12 @@ public static ScenarioObjective getPreventEnemyBreakthrough(AtBContract contract

ObjectiveEffect successEffect = new ObjectiveEffect();
successEffect.effectType = ObjectiveEffectType.ScenarioVictory;
successEffect.howMuch = 1;
successEffect.howMuch = OperationalVP;
destroyHostiles.addSuccessEffect(successEffect);

ObjectiveEffect failureEffect = new ObjectiveEffect();
failureEffect.effectType = ObjectiveEffectType.ScenarioDefeat;
failureEffect.howMuch = 1;
failureEffect.howMuch = OperationalVP;
destroyHostiles.addFailureEffect(failureEffect);

return destroyHostiles;
Expand All @@ -190,7 +190,7 @@ public static ScenarioObjective getPreventEnemyBreakthrough(AtBContract contract
/**
* Generates a "reach X edge with x% of all allied + player units" objective
*/
public static ScenarioObjective getBreakthrough(AtBContract contract, AtBScenario scenario, Campaign campaign,
public static ScenarioObjective getBreakthrough(AtBContract contract, AtBScenario scenario, Campaign campaign, int OperationalVP,
int percentage, OffBoardDirection direction) {
ScenarioObjective breakthrough = new ScenarioObjective();
breakthrough.setDescription(
Expand All @@ -204,12 +204,12 @@ public static ScenarioObjective getBreakthrough(AtBContract contract, AtBScenari

ObjectiveEffect successEffect = new ObjectiveEffect();
successEffect.effectType = ObjectiveEffectType.ScenarioVictory;
successEffect.howMuch = 1;
successEffect.howMuch = OperationalVP;
breakthrough.addSuccessEffect(successEffect);

ObjectiveEffect failureEffect = new ObjectiveEffect();
failureEffect.effectType = ObjectiveEffectType.ScenarioDefeat;
failureEffect.howMuch = 1;
failureEffect.howMuch = OperationalVP;
breakthrough.addFailureEffect(failureEffect);

return breakthrough;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList<Entity> allyEnti
public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 100);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this, 100, false);
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1, 100);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this, 1, 100, false);

getScenarioObjectives().add(destroyHostiles);
getScenarioObjectives().add(keepFriendliesAlive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public void setObjectives(Campaign campaign, AtBContract contract) {

String allyBotName = getContract(campaign).getAllyBotName();

ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 100);
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1, 100);
// this is a special case where the target is actually the "allied" bot.
destroyHostiles.clearForces();
destroyHostiles.addForce(allyBotName);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this, 100, false);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this, 1, 100, false);
keepFriendliesAlive.removeForce(allyBotName);

getScenarioObjectives().add(destroyHostiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList<Entity> allyEnti
public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 50);
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1, 50);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this,
50, false);
1, 50, false);

// in addition to the standard destroy 50/preserve 50, you need to keep
// at least 3/8 of the "allied" units alive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList<Entity> allyEnti
@Override
public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 66);
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1, 66);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this,
100, false);
1, 100, false);

getScenarioObjectives().add(destroyHostiles);
getScenarioObjectives().add(keepFriendliesAlive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList<Entity> allyEnti
public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 50);
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1, 50);
destroyHostiles.addForce(String.format("%s%s", contract.getEnemyBotName(), SECOND_ENEMY_FORCE_SUFFIX));
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this,
50, false);
1, 50, false);

ScenarioObjective preserveBaseUnits = null;
if (!isAttacker()) {
preserveBaseUnits = CommonObjectiveFactory.getPreserveSpecificFriendlies(BASE_CIVILIAN_FORCE_ID, 3, true);
preserveBaseUnits = CommonObjectiveFactory.getPreserveSpecificFriendlies(BASE_CIVILIAN_FORCE_ID, 1, 3, true);
preserveBaseUnits.addForce(BASE_TURRET_FORCE_ID);

ObjectiveEffect defeatEffect = new ObjectiveEffect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyHostiles = isAttacker()
? CommonObjectiveFactory.getBreakthrough(contract, this, campaign, 66,
? CommonObjectiveFactory.getBreakthrough(contract, this, campaign, 1, 66,
OffBoardDirection.getOpposite(OffBoardDirection.translateBoardStart(getStart())))
: CommonObjectiveFactory.getPreventEnemyBreakthrough(contract, 50,
: CommonObjectiveFactory.getPreventEnemyBreakthrough(contract, 1, 50,
OffBoardDirection.translateBoardStart(getEnemyHome()));
ScenarioObjective keepAttachedUnitsAlive = CommonObjectiveFactory.getKeepAttachedGroundUnitsAlive(contract,
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyHostiles = isAttacker()
? CommonObjectiveFactory.getBreakthrough(contract, this, campaign, 50,
? CommonObjectiveFactory.getBreakthrough(contract, this, campaign, 1, 50,
OffBoardDirection.translateBoardStart(AtBDynamicScenarioFactory.getOppositeEdge(getStart())))
: CommonObjectiveFactory.getPreventEnemyBreakthrough(contract, 50,
: CommonObjectiveFactory.getPreventEnemyBreakthrough(contract, 1, 50,
OffBoardDirection.translateBoardStart(getEnemyHome()));
ScenarioObjective keepAttachedUnitsAlive = CommonObjectiveFactory.getKeepAttachedGroundUnitsAlive(contract,
this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList<Entity> allyEnti
public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 66);
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1, 66);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this,
1, true);
1, 1, true);
ScenarioObjective keepCiviliansAlive = CommonObjectiveFactory.getPreserveSpecificFriendlies(CIVILIAN_FORCE_ID,
1, true);
1, 1, true);

// not losing the scenario also gets you a "bonus"
ObjectiveEffect bonusEffect = new ObjectiveEffect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList<Entity> allyEnti
public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyRioters = CommonObjectiveFactory.getDestroyEnemies(RIOTER_FORCE_ID, 100);
ScenarioObjective destroyRebels = CommonObjectiveFactory.getDestroyEnemies(REBEL_FORCE_ID, 50);
ScenarioObjective destroyRioters = CommonObjectiveFactory.getDestroyEnemies(RIOTER_FORCE_ID, 1, 100);
ScenarioObjective destroyRebels = CommonObjectiveFactory.getDestroyEnemies(REBEL_FORCE_ID, 1, 50);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this,
50, false);
1, 50, false);
ScenarioObjective keepLoyalistsAlive = CommonObjectiveFactory.getPreserveSpecificFriendlies(LOYALIST_FORCE_ID,
1, true);
1, 1, true);

// not losing the scenario also gets you a "bonus"
ObjectiveEffect bonusEffect = new ObjectiveEffect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList<Entity> allyEnti
public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyConvoy = CommonObjectiveFactory.getDestroyEnemies(CONVOY_FORCE_ID, 100);
ScenarioObjective destroyConvoy = CommonObjectiveFactory.getDestroyEnemies(CONVOY_FORCE_ID, 1, 100);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this,
50, false);
1, 50, false);

getScenarioObjectives().add(destroyConvoy);
getScenarioObjectives().add(keepFriendliesAlive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public void setExtraScenarioForces(Campaign campaign, ArrayList<Entity> allyEnti
public void setObjectives(Campaign campaign, AtBContract contract) {
super.setObjectives(campaign, contract);

ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 50);
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1, 50);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this,
50, false);
1, 50, false);
ScenarioObjective keepConvoyAlive = CommonObjectiveFactory.getPreserveSpecificFriendlies(CONVOY_FORCE_ID, 1,
true);
1, true);

// not losing the scenario also gets you a "bonus"
ObjectiveEffect bonusEffect = new ObjectiveEffect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ public void setObjectives(Campaign campaign, AtBContract contract) {
ScenarioObjective civilianObjective;

if (isAttacker()) {
civilianObjective = CommonObjectiveFactory.getPreserveSpecificFriendlies(CIVILIAN_FORCE_ID, 50, false);
keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this, 66, false);
civilianObjective = CommonObjectiveFactory.getPreserveSpecificFriendlies(CIVILIAN_FORCE_ID, 1, 50, false);
keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(campaign, contract, this, 1, 66, false);

civilianObjective.setTimeLimit(12);
civilianObjective.setTimeLimitAtMost(false);
Expand All @@ -156,11 +156,11 @@ public void setObjectives(Campaign campaign, AtBContract contract) {
civilianObjective.addDetail(String
.format(defaultResourceBundle.getString("commonObjectives.bonusRolls.text"), bonusEffect.howMuch));
} else {
civilianObjective = CommonObjectiveFactory.getDestroyEnemies(CIVILIAN_FORCE_ID, 100);
civilianObjective = CommonObjectiveFactory.getDestroyEnemies(CIVILIAN_FORCE_ID, 1, 100);
civilianObjective.setTimeLimit(10);
civilianObjective.setTimeLimitAtMost(true);
civilianObjective.setTimeLimitType(TimeLimitType.Fixed);
destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 33);
destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1, 33);
destroyHostiles.setTimeLimit(10);
destroyHostiles.setTimeLimitAtMost(true);
destroyHostiles.setTimeLimitType(TimeLimitType.Fixed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ public void setObjectives(Campaign campaign, AtBContract contract) {

// Attacker must destroy 50% and keep 66% alive
// Defender must destroy 33% and keep 50% alive
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract,
ScenarioObjective destroyHostiles = CommonObjectiveFactory.getDestroyEnemies(contract, 1,
isAttacker() ? 50 : 33);
ScenarioObjective keepFriendliesAlive = CommonObjectiveFactory.getKeepFriendliesAlive(
campaign, contract, this, isAttacker() ? 66 : 50, false);
campaign, contract, this, 1, isAttacker() ? 66 : 50, false);
ScenarioObjective keepAttachedUnitsAlive = CommonObjectiveFactory.getKeepAttachedGroundUnitsAlive(contract,
this);

Expand Down
Loading

0 comments on commit 52874d9

Please sign in to comment.