30
30
31
31
import megamek .common .Compute ;
32
32
import megamek .common .annotations .Nullable ;
33
- import megamek .common .enums .SkillLevel ;
34
33
import megamek .logging .MMLogger ;
35
34
import mekhq .MekHQ ;
36
35
import mekhq .campaign .Campaign ;
53
52
import static java .lang .Math .floor ;
54
53
import static megamek .codeUtilities .MathUtility .clamp ;
55
54
import static megamek .common .Compute .d6 ;
55
+ import static megamek .common .enums .SkillLevel .ELITE ;
56
+ import static megamek .common .enums .SkillLevel .GREEN ;
57
+ import static megamek .common .enums .SkillLevel .REGULAR ;
58
+ import static megamek .common .enums .SkillLevel .VETERAN ;
56
59
import static mekhq .campaign .mission .AtBContract .getEffectiveNumUnits ;
57
60
import static mekhq .campaign .randomEvents .GrayMonday .isGrayMonday ;
58
61
@@ -331,7 +334,7 @@ private void checkForSubcontracts(Campaign campaign, AtBContract contract, int u
331
334
setEnemyRating (contract , campaign .getGameYear ());
332
335
333
336
if (contract .getContractType ().isCadreDuty ()) {
334
- contract .setAllySkill (SkillLevel . GREEN );
337
+ contract .setAllySkill (GREEN );
335
338
contract .setAllyQuality (IUnitRating .DRAGOON_F );
336
339
}
337
340
@@ -415,7 +418,7 @@ protected AtBContract generateAtBSubcontract(Campaign campaign,
415
418
setEnemyRating (contract , campaign .getGameYear ());
416
419
417
420
if (contract .getContractType ().isCadreDuty ()) {
418
- contract .setAllySkill (SkillLevel . GREEN );
421
+ contract .setAllySkill (GREEN );
419
422
contract .setAllyQuality (IUnitRating .DRAGOON_F );
420
423
}
421
424
contract .calculateLength (campaign .getCampaignOptions ().isVariableContractLength ());
@@ -700,26 +703,29 @@ private void setContractClauses(AtBContract contract, int unitRatingMod, Campaig
700
703
mods .mods [i ] += missionMods [contract .getContractType ().ordinal ()][i ];
701
704
}
702
705
703
- if (Factions .getInstance ().getFaction (contract .getEmployerCode ()).isISMajorOrSuperPower ()) {
704
- mods .mods [CLAUSE_SALVAGE ] += -1 ;
706
+ Faction employerFaction = contract .getEmployerFaction ();
707
+
708
+ if (employerFaction .isISMajorOrSuperPower ()) {
709
+ mods .mods [CLAUSE_SALVAGE ] -= 1 ;
705
710
mods .mods [CLAUSE_TRANSPORT ] += 1 ;
706
- }
707
- if (AtBContract .isMinorPower (contract .getEmployerCode ())) {
708
- mods .mods [CLAUSE_SALVAGE ] += -2 ;
709
- }
710
- if (contract .getEmployerFaction ().isMercenary ()) {
711
- mods .mods [CLAUSE_COMMAND ] += -1 ;
711
+ } else if (employerFaction .isMinorPower ()) {
712
+ mods .mods [CLAUSE_SALVAGE ] -= 2 ;
713
+ } else if (employerFaction .isMercenary ()) {
714
+ mods .mods [CLAUSE_COMMAND ] -= 1 ;
712
715
mods .mods [CLAUSE_SALVAGE ] += 2 ;
713
716
mods .mods [CLAUSE_SUPPORT ] += 1 ;
714
717
mods .mods [CLAUSE_TRANSPORT ] += 1 ;
715
- }
716
- if (contract .getEmployerCode ().equals ("IND" )) {
717
- mods .mods [CLAUSE_COMMAND ] += 0 ;
718
- mods .mods [CLAUSE_SALVAGE ] += -1 ;
719
- mods .mods [CLAUSE_SUPPORT ] += -1 ;
720
- mods .mods [CLAUSE_TRANSPORT ] += 0 ;
718
+ } else if (employerFaction .getShortName ().equals ("IND" )) {
719
+ mods .mods [CLAUSE_SALVAGE ] -= 1 ;
720
+ mods .mods [CLAUSE_SUPPORT ] -= 1 ;
721
721
}
722
722
723
+ int modifier = getEmployerNegotiatorModifier (employerFaction );
724
+ mods .mods [CLAUSE_COMMAND ] -= modifier ;
725
+ mods .mods [CLAUSE_SALVAGE ] -= modifier ;
726
+ mods .mods [CLAUSE_SUPPORT ] -= modifier ;
727
+ mods .mods [CLAUSE_TRANSPORT ] -= modifier ;
728
+
723
729
if (campaign .getFaction ().isMercenary ()) {
724
730
rollCommandClause (contract , mods .mods [CLAUSE_COMMAND ]);
725
731
} else {
@@ -730,4 +736,32 @@ private void setContractClauses(AtBContract contract, int unitRatingMod, Campaig
730
736
rollSupportClause (contract , mods .mods [CLAUSE_SUPPORT ]);
731
737
rollTransportClause (contract , mods .mods [CLAUSE_TRANSPORT ]);
732
738
}
739
+
740
+ /**
741
+ * Calculates the negotiation modifier for a contract based on the employer's faction type.
742
+ * The modifier reflects the negotiation capabilities of the employer, making it harder to
743
+ * achieve favorable results with more influential or powerful employers.
744
+ *
745
+ * <p>The negotiation modifier is determined as follows:
746
+ * <ul>
747
+ * <li>Default: A "Green" modifier is used for most employers.</li>
748
+ * <li>Major or superpower faction: A "Regular" modifier is applied.</li>
749
+ * <li>Clan faction: A "Veteran" modifier is applied.</li>
750
+ * <li>ComStar or Word of Blake (WoB): An "Elite" modifier is applied.</li>
751
+ * </ul>
752
+ *
753
+ * @param employerFaction The {@link Faction} that is performing the negotiation.
754
+ * @return An integer representing the negotiation modifier corresponding to the employer's capabilities.
755
+ */
756
+ private static int getEmployerNegotiatorModifier (Faction employerFaction ) {
757
+ if (employerFaction .isMajorOrSuperPower ()) {
758
+ return REGULAR .getExperienceLevel ();
759
+ } else if (employerFaction .isClan ()) {
760
+ return VETERAN .getExperienceLevel ();
761
+ } else if (employerFaction .isComStarOrWoB ()) {
762
+ return ELITE .getExperienceLevel ();
763
+ }
764
+
765
+ return GREEN .getExperienceLevel ();
766
+ }
733
767
}
0 commit comments