@@ -1962,8 +1962,6 @@ public static Entity getEntity(String faction, SkillLevel skill, int quality, in
1962
1962
params .setYear (campaign .getGameYear ());
1963
1963
params .setMissionRoles (rolesByType );
1964
1964
1965
- // Special handling for pre-Tukayyid, where Clan units shouldn't be appearing in non-Clan forces. Clan
1966
- // tech, at that time, would be closely guarded and not something we want OpFors to be generating with
1967
1965
if (filterOutClanTech (campaign , isFactionClan (factionCode ))) {
1968
1966
params .setFilter (mekSummary -> !mekSummary .isClan () &&
1969
1967
(unitType == GUN_EMPLACEMENT || mekSummary .getWalkMp () >= 1 ));
@@ -1990,10 +1988,6 @@ public static Entity getEntity(String faction, SkillLevel skill, int quality, in
1990
1988
return createEntityWithCrew (factionCode , skill , campaign , unitData );
1991
1989
}
1992
1990
1993
- private static boolean isBeforeBattleOfTukayyid (Campaign campaign ) {
1994
- return campaign .getLocalDate ().isBefore (BATTLE_OF_TUKAYYID );
1995
- }
1996
-
1997
1991
/**
1998
1992
* Determines whether the weight class constraints should be bypassed based on the given mission roles.
1999
1993
* <p>
@@ -2055,8 +2049,6 @@ public static Entity getTankEntity(UnitGeneratorParameters params, SkillLevel sk
2055
2049
if (campaign .getCampaignOptions ().isOpForUsesVTOLs ()) {
2056
2050
params .getMovementModes ().addAll (IUnitGenerator .MIXED_TANK_VTOL );
2057
2051
} else {
2058
- // Special handling for pre-Tukayyid, where Clan units shouldn't be appearing in non-Clan forces. Clan
2059
- // tech, at that time, would be closely guarded and not something we want OpFors to be generating with
2060
2052
if (filterOutClanTech (campaign , isFactionClan (params .getFaction ()))) {
2061
2053
params .setFilter (mekSummary -> !mekSummary .isClan () && !mekSummary .getUnitType ().equals ("VTOL" ));
2062
2054
} else {
@@ -2083,8 +2075,50 @@ public static Entity getTankEntity(UnitGeneratorParameters params, SkillLevel sk
2083
2075
return createEntityWithCrew (params .getFaction (), skill , campaign , unitData );
2084
2076
}
2085
2077
2078
+ /**
2079
+ * Filters out Clan technology based on the campaign timeline and unit type.
2080
+ *
2081
+ * <p>Special handling for pre-Tukayyid, where Clan units shouldn't be appearing in non-Clan forces. Clan tech,
2082
+ * at that time, would be closely guarded and not something we want OpFors to be generating with.</p>
2083
+ *
2084
+ * @param campaign The campaign object which contains timeline details.
2085
+ * @param isClan A boolean indicating whether the unit is Clan technology.
2086
+ *
2087
+ * @return {@code true} if the unit should be filtered out (not Clan and before the Battle of Tukayyid),
2088
+ * {@code false} otherwise.
2089
+ *
2090
+ * @author Illiani
2091
+ * @since 0.50.05
2092
+ */
2086
2093
private static boolean filterOutClanTech (Campaign campaign , boolean isClan ) {
2087
- return isBeforeBattleOfTukayyid (campaign ) && !isClan ;
2094
+ boolean isBeforeTukayyid = campaign .getLocalDate ().isBefore (BATTLE_OF_TUKAYYID );
2095
+
2096
+ return isBeforeTukayyid && !isClan ;
2097
+ }
2098
+
2099
+ /**
2100
+ * Checks whether a given faction, identified by its name or identifier, belongs to the Clan faction group.
2101
+ *
2102
+ * <p>If the specified faction code cannot be parsed into a {@link Faction}, a warning is logged and {@code false}
2103
+ * is returned.</p>
2104
+ *
2105
+ * @param params the name or identifier of the faction to check
2106
+ *
2107
+ * @return {@code true} if the specified faction exists and is classified as a Clan faction; {@code false} if the
2108
+ * faction does not exist or is not a Clan faction
2109
+ *
2110
+ * @author Illiani
2111
+ * @since 0.50.05
2112
+ */
2113
+ private static boolean isFactionClan (String params ) {
2114
+ Faction faction = Factions .getInstance ().getFaction (params );
2115
+
2116
+ if (faction == null ) {
2117
+ logger .warn ("AtBDynamicScenarioFactory#isFactionClan) Faction {} does not exist." , params );
2118
+ return false ;
2119
+ }
2120
+
2121
+ return faction .isClan ();
2088
2122
}
2089
2123
2090
2124
/**
@@ -2404,8 +2438,6 @@ private static List<Entity> fillTransport(AtBScenario scenario, Entity transport
2404
2438
newParams .getMovementModes ().add (EntityMovementMode .INF_LEG );
2405
2439
}
2406
2440
2407
- // Special handling for pre-Tukayyid, where Clan units shouldn't be appearing in non-Clan forces. Clan
2408
- // tech, at that time, would be closely guarded and not something we want OpFors to be generating with
2409
2441
if (filterOutClanTech (campaign , isFactionClan (params .getFaction ()))) {
2410
2442
params .setFilter (mekSummary -> !mekSummary .isClan () &&
2411
2443
mekSummary .getTons () <=
@@ -2448,8 +2480,6 @@ private static List<Entity> fillTransport(AtBScenario scenario, Entity transport
2448
2480
} else {
2449
2481
newParams .getMovementModes ().addAll (IUnitGenerator .ALL_INFANTRY_MODES );
2450
2482
2451
- // Special handling for pre-Tukayyid, where Clan units shouldn't be appearing in non-Clan forces. Clan
2452
- // tech, at that time, would be closely guarded and not something we want OpFors to be generating with
2453
2483
if (filterOutClanTech (campaign , isFactionClan (params .getFaction ()))) {
2454
2484
params .setFilter (mekSummary -> !mekSummary .isClan () && mekSummary .getTons () <= bayCapacity );
2455
2485
} else {
@@ -2514,8 +2544,6 @@ private static List<Entity> fillTransport(AtBScenario scenario, Entity transport
2514
2544
// Set the parameters to filter out types that are too heavy for the provided
2515
2545
// bay space, or those that cannot use mechanized BA travel
2516
2546
if (bayCapacity != IUnitGenerator .NO_WEIGHT_LIMIT ) {
2517
- // Special handling for pre-Tukayyid, where Clan units shouldn't be appearing in non-Clan forces. Clan
2518
- // tech, at that time, would be closely guarded and not something we want OpFors to be generating with
2519
2547
if (filterOutClanTech (campaign , isFactionClan (params .getFaction ()))) {
2520
2548
params .setFilter (mekSummary -> !mekSummary .isClan () && mekSummary .getTons () <= bayCapacity );
2521
2549
} else {
@@ -2531,8 +2559,6 @@ private static List<Entity> fillTransport(AtBScenario scenario, Entity transport
2531
2559
// If generating for an internal bay fails, try again as mechanized if the flag is set
2532
2560
if (unitData == null ) {
2533
2561
if (newParams != null && bayCapacity != IUnitGenerator .NO_WEIGHT_LIMIT && retryAsMechanized ) {
2534
- // Special handling for pre-Tukayyid, where Clan units shouldn't be appearing in non-Clan forces. Clan
2535
- // tech, at that time, would be closely guarded and not something we want OpFors to be generating with
2536
2562
if (filterOutClanTech (campaign , isFactionClan (params .getFaction ()))) {
2537
2563
params .setFilter (mekSummary -> !mekSummary .isClan ());
2538
2564
} else {
@@ -2555,12 +2581,6 @@ private static List<Entity> fillTransport(AtBScenario scenario, Entity transport
2555
2581
}
2556
2582
}
2557
2583
2558
- private static boolean isFactionClan (String params ) {
2559
- Faction faction = Factions .getInstance ().getFaction (params );
2560
- boolean isClan = faction != null && faction .isClan ();
2561
- return isClan ;
2562
- }
2563
-
2564
2584
/**
2565
2585
* Generates and associates Battle Armor units with a designated transport.
2566
2586
*
0 commit comments