@@ -400,6 +400,37 @@ public Map<Attribute, Double> calculateBrandsetBonus(Inventory inventory) {
400400 Map <String , Integer > manuBonus = new HashMap <>();
401401 Map <Attribute , Double > brandsetBonus = new HashMap <>();
402402
403+ sumBrandset (inventory , manuBonus );
404+
405+ // Loop over the brandset bonus and sum up all the specific values
406+ manuBonus .forEach (
407+ (manufacturer , amount ) -> {
408+
409+ if (amount > 0 ) {
410+ Manufacturer manu = (Manufacturer )World .Registry .get ("manufacturer" , manufacturer );
411+
412+ // Return the bonus for 3, 2 or 1 set item
413+ // see Manufacturer class
414+ Map <Attribute , Double > attributesAndValuesSingle = manu .getAttributesAndValues (amount );
415+ attributesAndValuesSingle .forEach (
416+ (attribute , attributeValue ) -> brandsetBonus .merge (attribute , attributeValue , Double ::sum )
417+ );
418+ }
419+ }
420+ );
421+
422+ // i.e. for 2 Parts Providence, 1 Part Overlord, 1 part Grupo, 1 Part Ceska
423+ // Result is: Weapon Damage can be read over
424+ // {WEAPONDAMAGE=0.0, HEADSHOTDAMAGE=15.0, CRITICALHITCHANCE=20.0, RIFLEDAMAGE=10.0, CRITICALHITDAMAGE=15.0}
425+ return brandsetBonus ;
426+ }
427+
428+ /**
429+ *
430+ * @param inventory Classic inventory
431+ * @param manuBonus Bonus collection where to store the sum for the brandsets
432+ */
433+ private void sumBrandset (Inventory inventory , Map <String , Integer > manuBonus ) {
403434 // Initialize manufacturer bonus array
404435 for (String manufacturer : Manufacturer .manufacturerList ) {
405436 manuBonus .put (manufacturer , 0 );
@@ -421,30 +452,31 @@ public Map<Attribute, Double> calculateBrandsetBonus(Inventory inventory) {
421452 }
422453 }
423454 }
455+ }
456+
457+ /**
458+ * Returns the bonus by brandset
459+ * @param inventory
460+ * @return
461+ */
462+ public Map <String , Map <Attribute , Double >> getBonusByBrandset (Inventory inventory ) {
424463
425- // Loop over the brandset bonus and sum up all the specific values
426- manuBonus .forEach (
427- (manufacturer , amount ) -> {
428-
429- if (amount > 0 ) {
430- Manufacturer manu = (Manufacturer )World .Registry .get ("manufacturer" , manufacturer );
431-
432- // Return the bonus for 3, 2 or 1 set item
433- // see Manufacturer class
434- Map <Attribute , Double > attributesAndValuesSingle = manu .getAttributesAndValues (amount );
435- attributesAndValuesSingle .forEach (
436- (attribute , attributeValue ) -> brandsetBonus .merge (attribute , attributeValue , Double ::sum )
437- );
438- }
464+ Map <String , Integer > manuBonus = new HashMap <>();
465+ Map <String , Map <Attribute , Double >> returnValue = new HashMap <>();
466+
467+ sumBrandset (inventory , manuBonus );
468+
469+ manuBonus .forEach ((manufacturer , amount ) -> {
470+ if (amount > 0 ) {
471+ Manufacturer manu = (Manufacturer ) World .Registry .get ("manufacturer" , manufacturer );
472+ returnValue .put (manufacturer , manu .getAttributesAndValues (amount ));
439473 }
440- );
474+ } );
441475
442- // i.e. for 2 Parts Providence, 1 Part Overlord, 1 part Grupo, 1 Part Ceska
443- // Result is: Weapon Damage can be read over
444- // {WEAPONDAMAGE=0.0, HEADSHOTDAMAGE=15.0, CRITICALHITCHANCE=20.0, RIFLEDAMAGE=10.0, CRITICALHITDAMAGE=15.0}
445- return brandsetBonus ;
476+ return returnValue ;
446477 }
447478
479+
448480 /**
449481 * Calculates the statistics, accumulates them and put in in the internal statistic map
450482 * @param inventory Inventory with all the slots and equipment
@@ -459,12 +491,7 @@ public Map<String, Map<Attribute, Double>> calculate(Inventory inventory) {
459491 brandsetStats = calculateBrandsetBonus (inventory );
460492 weaponStats = calculateWeaponBonus (inventory );
461493 colors = determineRedYellowBlueColors (inventory );
462-
463- // System.out.println("Player " + playerStats);
464- // System.out.println("Weapon " + weaponStats.get("PRIMARY"));
465- // System.out.println("Brandset " + brandsetStats);
466- // System.out.println("Equipment " + equipmentStats);
467-
494+
468495 // Calculate the bonus for primary weapon, secondary weapon and pistol and combination with the other stats
469496 Map <Attribute , Double > attributesAndValues = null ;
470497 for (String slot : slotList ) {
0 commit comments