2020import java .nio .file .StandardCopyOption ;
2121import java .time .LocalDateTime ;
2222import java .util .*;
23+ import java .util .concurrent .ConcurrentSkipListSet ;
2324import java .util .concurrent .CopyOnWriteArraySet ;
2425import java .util .stream .Collectors ;
2526import java .util .stream .Stream ;
@@ -122,6 +123,7 @@ public void printCardForArmyCode(List<UnitOption> unitOptions,
122123 String armyCode ,
123124 boolean useInch ,
124125 boolean showSavingRollInsteadOfAmmo ,
126+ boolean removeDuplicates ,
125127 boolean reduceColor ,
126128 Set <Weapon .Type > showWeaponOfType ,
127129 boolean showImage ,
@@ -143,6 +145,7 @@ public void printCardForArmyCode(List<UnitOption> unitOptions,
143145 CARD_FOLDER ,
144146 useInch ,
145147 showSavingRollInsteadOfAmmo ,
148+ removeDuplicates ,
146149 reduceColor ,
147150 showWeaponOfType ,
148151 showImage ,
@@ -266,6 +269,7 @@ public void writeToFile(UnitOption unitOption,
266269 outputFolder ,
267270 useInch ,
268271 showSavingRollInsteadOfAmmo ,
272+ false ,
269273 reduceColor ,
270274 Set .of (Weapon .Type .WEAPON , Weapon .Type .EQUIPMENT , Weapon .Type .SKILL ),
271275 true ,
@@ -289,6 +293,7 @@ public void writeCards(List<UnitOption> unitOptions,
289293 String outputFolder ,
290294 boolean useInch ,
291295 boolean showSavingRollInsteadOfAmmo ,
296+ boolean removeDuplicates ,
292297 boolean reduceColor ,
293298 Set <Weapon .Type > showWeaponOfType ,
294299 boolean showImage ,
@@ -335,10 +340,26 @@ public void writeCards(List<UnitOption> unitOptions,
335340 boarderColor = SECTORIAL_COLORS .get (sectorial .getParentId () - 1 );
336341 }
337342
338-
339- List <UnitPrintCard > unitPrintCards = unitOptions .stream ()
340- .flatMap (u -> UnitPrintCard .fromUnitOption (u , useInch , showWeaponOfType , showImage , allMartialArtLevels ).stream ())
341- .toList ();
343+ final List <UnitPrintCard > unitPrintCards ;
344+ if (removeDuplicates ) {
345+ Set <String > ids = new ConcurrentSkipListSet <>();
346+ unitPrintCards = unitOptions .stream ()
347+ .flatMap (u -> UnitPrintCard .fromUnitOption (u , useInch , showWeaponOfType , showImage , allMartialArtLevels , null ).stream ())
348+ .filter (u -> {
349+ if (ids .contains (u .getCombinedProfileId ())) {
350+ return false ;
351+ } else {
352+ ids .add (u .getCombinedProfileId ());
353+ return true ;
354+ }
355+ })
356+ .toList ();
357+ } else {
358+ unitPrintCards = armyList .getCombatGroups ().entrySet ().stream ()
359+ .flatMap (e -> e .getValue ().stream ()
360+ .flatMap (uo -> UnitPrintCard .fromUnitOption (uo , useInch , showWeaponOfType , showImage , allMartialArtLevels , e .getKey ()).stream ())
361+ ).toList ();
362+ }
342363
343364 List <PrintHackingProgram > usedHackingPrograms = showHackingPrograms ? getUsedHackingPrograms (unitOptions , allHackingPrograms ) : List .of ();
344365
0 commit comments