38
38
import megamek .client .ratgenerator .FactionRecord ;
39
39
import megamek .client .ratgenerator .MissionRole ;
40
40
import megamek .client .ratgenerator .ModelRecord ;
41
+ import megamek .client .ratgenerator .Parameters ;
41
42
import megamek .client .ratgenerator .RATGenerator ;
42
43
import megamek .client .ratgenerator .UnitTable ;
43
44
import megamek .common .EntityMovementMode ;
47
48
import megamek .logging .MMLogger ;
48
49
49
50
/**
50
- * Provides access to RATGenerator through the AbstractUnitGenerator and thus
51
- * the IUnitGenerator interface.
51
+ * Provides access to RATGenerator through the AbstractUnitGenerator and thus the IUnitGenerator interface.
52
52
*
53
53
* @author Neoancient
54
54
*/
@@ -70,9 +70,8 @@ public RATGeneratorConnector(final int year) {
70
70
}
71
71
72
72
private @ Nullable UnitTable findTable (final String faction , final int unitType , final int weightClass ,
73
- final int year , final int quality ,
74
- final Collection <EntityMovementMode > movementModes ,
75
- final Collection <MissionRole > missionRoles ) {
73
+ final int year , final int quality , final Collection <EntityMovementMode > movementModes ,
74
+ final Collection <MissionRole > missionRoles ) {
76
75
final FactionRecord factionRecord = Factions .getInstance ().getFactionRecordOrFallback (faction );
77
76
if (factionRecord == null ) {
78
77
return null ;
@@ -82,17 +81,25 @@ public RATGeneratorConnector(final int year) {
82
81
if (weightClass >= 0 ) {
83
82
weightClasses .add (weightClass );
84
83
}
85
- return UnitTable .findTable (factionRecord , unitType , year , rating , weightClasses , ModelRecord .NETWORK_NONE ,
86
- movementModes , missionRoles , 2 , factionRecord );
84
+ return UnitTable .findTable (factionRecord ,
85
+ unitType ,
86
+ year ,
87
+ rating ,
88
+ weightClasses ,
89
+ ModelRecord .NETWORK_NONE ,
90
+ movementModes ,
91
+ missionRoles ,
92
+ 2 ,
93
+ factionRecord );
87
94
}
88
95
89
96
/**
90
- * Helper function that extracts the string-based unit rating from the given
91
- * int-based unit-rating
92
- * for the given faction.
97
+ * Helper function that extracts the string-based unit rating from the given int-based unit-rating for the given
98
+ * faction.
93
99
*
94
100
* @param factionRecord Faction record
95
101
* @param quality Unit quality number
102
+ *
96
103
* @return Unit quality string
97
104
*/
98
105
public static String getFactionSpecificRating (final FactionRecord factionRecord , final int quality ) {
@@ -116,29 +123,23 @@ public boolean isSupportedUnitType(final int unitType) {
116
123
117
124
@ Override
118
125
public @ Nullable MekSummary generate (final String faction , final int unitType , final int weightClass ,
119
- final int year , final int quality ,
120
- final Collection <EntityMovementMode > movementModes ,
121
- final Collection <MissionRole > missionRoles ,
122
- @ Nullable Predicate <MekSummary > filter ) {
126
+ final int year , final int quality , final Collection <EntityMovementMode > movementModes ,
127
+ final Collection <MissionRole > missionRoles , @ Nullable Predicate <MekSummary > filter ) {
123
128
final UnitTable table = findTable (faction , unitType , weightClass , year , quality , movementModes , missionRoles );
124
129
return (table == null ) ? null : table .generateUnit ((filter == null ) ? null : filter ::test );
125
130
}
126
131
127
132
@ Override
128
133
public List <MekSummary > generate (final int count , final String faction , final int unitType , final int weightClass ,
129
- final int year , final int quality ,
130
- final Collection <EntityMovementMode > movementModes ,
131
- final Collection <MissionRole > missionRoles ,
132
- @ Nullable Predicate <MekSummary > filter ) {
134
+ final int year , final int quality , final Collection <EntityMovementMode > movementModes ,
135
+ final Collection <MissionRole > missionRoles , @ Nullable Predicate <MekSummary > filter ) {
133
136
final UnitTable table = findTable (faction , unitType , weightClass , year , quality , movementModes , missionRoles );
134
137
return (table == null ) ? new ArrayList <>() : table .generateUnits (count , (filter == null ) ? null : filter ::test );
135
138
}
136
139
137
140
/**
138
- * Generates a list of mek summaries from a RAT determined by the given faction,
139
- * quality and other parameters.
140
- * We force a fallback to try to ensure that something is generated if the
141
- * parents have any possible units to generate,
141
+ * Generates a list of mek summaries from a RAT determined by the given faction, quality and other parameters. We
142
+ * force a fallback to try to ensure that something is generated if the parents have any possible units to generate,
142
143
* as that is the normally expected behaviour for MekHQ OpFor generation.
143
144
*
144
145
* @param count How many units to generate
@@ -148,15 +149,13 @@ public List<MekSummary> generate(final int count, final String faction, final in
148
149
public List <MekSummary > generate (final int count , final UnitGeneratorParameters parameters ) {
149
150
final UnitTable table = findOpForTable (parameters );
150
151
return table .generateUnits (count ,
151
- (parameters .getFilter () == null ) ? null : ms -> parameters .getFilter ().test (ms ));
152
+ (parameters .getFilter () == null ) ? null : ms -> parameters .getFilter ().test (ms ));
152
153
}
153
154
154
155
/**
155
- * Generates a single mek summary from a RAT determined by the given faction,
156
- * quality and other parameters.
157
- * We force a fallback to try to ensure that something is generated if the
158
- * parents have any possible units to generate,
159
- * as that is the normally expected behaviour for MekHQ OpFor generation.
156
+ * Generates a single mek summary from a RAT determined by the given faction, quality and other parameters. We force
157
+ * a fallback to try to ensure that something is generated if the parents have any possible units to generate, as
158
+ * that is the normally expected behaviour for MekHQ OpFor generation.
160
159
*
161
160
* @param parameters RATGenerator parameters
162
161
*/
@@ -167,15 +166,15 @@ public List<MekSummary> generate(final int count, final UnitGeneratorParameters
167
166
}
168
167
169
168
/**
170
- * This finds a unit table for OpFor generation. It falls back using the parent
171
- * faction to try to ensure there are
169
+ * This finds a unit table for OpFor generation. It falls back using the parent faction to try to ensure there are
172
170
* units in the unit table, so an OpFor is generated.
173
171
*
174
172
* @param unitParameters the base parameters to find the table using.
173
+ *
175
174
* @return the unit table to use in generating OpFor mek summaries
176
175
*/
177
176
private UnitTable findOpForTable (final UnitGeneratorParameters unitParameters ) {
178
- final UnitTable . Parameters parameters = unitParameters .getRATGeneratorParameters ();
177
+ final Parameters parameters = unitParameters .getRATGeneratorParameters ();
179
178
UnitTable table = UnitTable .findTable (parameters );
180
179
if (!table .hasUnits ()) {
181
180
// Do Parent Factions Fallbacks to try to ensure units can be generated, at a
0 commit comments