-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
286 lines (227 loc) · 10.2 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MilitarySymbols;
namespace CodePermutations
{
/// <summary>
/// This utility is mainly intended to be used to create batch scripts for testing
/// all combinations of a symbol
/// </summary>
class Program
{
static void Main(string[] args)
{
string sidc = "10121100";
if (args.Length < 1)
{
Usage();
}
else
{
sidc = args[0];
}
if (sidc.StartsWith("ALL"))
ProcessAll();
else
if ((sidc.Length == 20) || (sidc.Length == 8)) // (full or shortened) code supplied
ProcessSidc(sidc);
else
Usage();
}
static void Usage()
{
Console.WriteLine("CodePermutations [SymbolIDCode]");
}
static string delimiter = " "; // ",";
static string baseString = " "; // Ex: "ExportBitmap.exe"
static string commentString = "REM";
static void PrintCommentLine(string comment)
{
// just prints a formatted row with the comment and the same number of delimiters as PrintCodeLine
if (!string.IsNullOrWhiteSpace(baseString))
Console.Write(commentString + delimiter);
Console.Write(comment);
Console.WriteLine(delimiter + delimiter + delimiter);
}
static void PrintCodeLine(SymbolIdCode sidc, string optionalTag = "")
{
string simpleCode = sidc.HumanReadableCode(false);
if (!string.IsNullOrWhiteSpace(baseString))
Console.Write(baseString + delimiter);
Console.Write(sidc.Code + delimiter +
simpleCode + delimiter + sidc.Name + delimiter);
if (!string.IsNullOrWhiteSpace(optionalTag))
Console.WriteLine(optionalTag);
else
Console.WriteLine();
}
static void ProcessSidc(string sidcString)
{
// base code
SymbolIdCode sidc = new SymbolIdCode(sidcString);
if (!sidc.IsValid)
{
Console.WriteLine("Could not create symbol from SIDC: " + sidcString);
return;
}
if (TypeUtilities.IsWeather(sidc.SymbolSet))
{
// create a one version & then return, the rest don't apply
PrintCommentLine("Weather Symbol Set: " + sidc.SymbolSet);
PrintCodeLine(sidc, "Weather - only one version of symbol");
return;
}
bool hasFrame = TypeUtilities.HasFrame(sidc.SymbolSet);
PrintCommentLine("Affiliation/Planning Combinations");
List<Enum> enums = TypeUtilities.EnumHelper.getEnumValues(typeof(StandardIdentityAffiliationType));
foreach (Enum en in enums)
{
sidc.Affiliation = (StandardIdentityAffiliationType)en;
string tag = TypeUtilities.EnumHelper.getStringFromEnum(en);
if ((tag != "NotSet") && (tag != "Dont Display Frame"))
{
PrintCodeLine(sidc, tag);
// create a planning version
sidc.Status = StatusType.Planned_Anticipated_Suspect;
PrintCodeLine(sidc, "Planning");
sidc.Status = StatusType.Present; // Reset
// if it has a frame also do the Real/Exercise/Sim combos
if ((hasFrame) &&
((sidc.Affiliation == StandardIdentityAffiliationType.Friend) ||
(sidc.Affiliation == StandardIdentityAffiliationType.Hostile) ||
(sidc.Affiliation == StandardIdentityAffiliationType.Suspect_Joker) ||
(sidc.Affiliation == StandardIdentityAffiliationType.Neutral) ||
(sidc.Affiliation == StandardIdentityAffiliationType.Unknown)))
{
PrintCommentLine("StandardIdentity Combinations for affiliation: " + en);
List<Enum> enums2 = TypeUtilities.EnumHelper.getEnumValues(typeof(StandardIdentityRealExerciseSimType));
foreach (Enum en2 in enums2)
{
sidc.StandardIdentity = (StandardIdentityRealExerciseSimType)en2;
string tag2 = TypeUtilities.EnumHelper.getStringFromEnum(en2);
if (tag2 != "NotSet")
PrintCodeLine(sidc, tag2);
}
// Reset
sidc.StandardIdentity = StandardIdentityRealExerciseSimType.Reality;
}
}
}
// Reset
sidc.Affiliation = StandardIdentityAffiliationType.Friend;
// Does it have a frame? If not don't need to do the rest
if (!hasFrame)
{
PrintCommentLine("Non-framed Symbol Set: " + sidc.SymbolSet + " - done");
return;
}
if (TypeUtilities.HasFrameModifiers(sidc.SymbolSet))
{
PrintCommentLine("Headquarters/Task Force/Feint/Dummy Combinations");
enums = TypeUtilities.EnumHelper.getEnumValues(typeof(HeadquartersTaskForceDummyType));
foreach (Enum en in enums)
{
sidc.HeadquartersTaskForceDummy = (HeadquartersTaskForceDummyType)en;
string tag = TypeUtilities.EnumHelper.getStringFromEnum(en);
PrintCodeLine(sidc, tag);
}
// Reset
sidc.HeadquartersTaskForceDummy = HeadquartersTaskForceDummyType.NoHQTFDummyModifier;
PrintCommentLine("Echelon/Mobility Combinations");
enums = TypeUtilities.EnumHelper.getEnumValues(typeof(EchelonMobilityType));
foreach (Enum en in enums)
{
sidc.EchelonMobility = (EchelonMobilityType)en;
string tag = TypeUtilities.EnumHelper.getStringFromEnum(en);
PrintCodeLine(sidc, tag);
}
// Reset
sidc.EchelonMobility = EchelonMobilityType.NoEchelonMobility;
}
SymbolLookup sl = Utilities.GetSymbolLookup();
CentralIconType iconType = sl.GetEntityIconTypeFromCode(sidc.SymbolSet, sidc.EntityCode);
if (iconType == CentralIconType.FULL_OCTAGON)
{
// Then we are done, no need for modifiers
return;
}
if (iconType != CentralIconType.MAIN_1) // can't have modifier 1
{
PrintCommentLine("Modifier 1 Code Combinations");
// Add all the modifiers
List<string> modifierCode1s = sl.GetModifierCodesForSymbolSet(sidc.SymbolSet, 1);
foreach (string mod1 in modifierCode1s)
{
sidc.ModifierOne = mod1;
string tag = sl.GetModifierNameFromCode(sidc.SymbolSet, 1, mod1);
PrintCodeLine(sidc, tag);
}
}
// Reset
sidc.ModifierOne = "00";
if (iconType != CentralIconType.MAIN_2) // can't have modifier 1
{
PrintCommentLine("Modifier 2 Code Combinations");
List<string> modifierCode2s = sl.GetModifierCodesForSymbolSet(sidc.SymbolSet, 2);
foreach (string mod2 in modifierCode2s)
{
sidc.ModifierTwo = mod2;
string tag = sl.GetModifierNameFromCode(sidc.SymbolSet, 2, mod2);
PrintCodeLine(sidc, tag);
}
}
// Reset
sidc.ModifierTwo = "00";
// Add those "Special Land Unit Entity Subtype combos in Land Unit
if (sidc.SymbolSet == SymbolSetType.Land_Unit)
{
List<string> specialSubTypes = new List<string>() { "95", "96", "97", "98" };
foreach (string subType in specialSubTypes)
{
sidc.EntitySubTypeField = subType;
PrintCodeLine(sidc, subType);
}
}
}
static void ProcessAll()
{
SymbolLookup sl = Utilities.GetSymbolLookup();
// Foreach symbol set pick a random entity and generate a symbol with permutations
SymbolSetType symbolSet = SymbolSetType.NotSet;
Random random = new Random();
// find the symbol set selected
List<Enum> symbolSetEnums = TypeUtilities.EnumHelper.getEnumValues(typeof(SymbolSetType));
foreach (Enum en in symbolSetEnums)
{
symbolSet = (SymbolSetType)en;
if (symbolSet == SymbolSetType.NotSet)
continue;
List<MilitarySymbol> allSymbolsFromSet = Utilities.GetMilitarySymbols(symbolSet);
int setCount = allSymbolsFromSet.Count;
if (setCount <= 0)
{
System.Diagnostics.Trace.WriteLine("No Symbols found in SymbolSet: " + symbolSet);
continue;
}
int randomOne = random.Next(0, setCount - 1);
MilitarySymbol symbol = allSymbolsFromSet[randomOne];
ProcessSidc(symbol.Id.Code);
}
}
}
}