Skip to content

Commit 410c89c

Browse files
committed
Deviding statistic into the primary, secondary, pistol data. Integrating
the basestats and brandsets. Additionally the Keener action updates now the tabletreeview.
1 parent 275e47e commit 410c89c

File tree

10 files changed

+282
-109
lines changed

10 files changed

+282
-109
lines changed

src/main/java/at/droll/div2builder/core/Manufacturer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package at.droll.div2builder.core;
22

3-
import java.io.Serializable;
43
import java.util.HashMap;
54
import java.util.Map;
65

src/main/java/at/droll/div2builder/core/World.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
package at.droll.div2builder.core;
22

3-
import java.io.FileInputStream;
4-
import java.io.FileOutputStream;
5-
import java.io.IOException;
6-
import java.io.ObjectInputStream;
7-
import java.io.ObjectOutputStream;
8-
import java.io.Serializable;
3+
94
import java.sql.Connection;
105
import java.sql.DriverManager;
116
import java.sql.ResultSet;
127
import java.sql.SQLException;
138
import java.sql.Statement;
149
import java.util.HashMap;
15-
import java.util.Map;
1610

1711
import at.droll.div2builder.core.attribute.*;
1812
import at.droll.div2builder.core.item.equipment.Equipment;

src/main/java/at/droll/div2builder/core/inventory/Loadout.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ public String getName()
4343
}
4444

4545
/**
46-
* Return the invventory
47-
* @return Returns the Inventory
46+
* Returns the inventory
47+
* @return Returns the tnventory
4848
*/
49-
public Inventory getInvetory() {
49+
public Inventory getInventory() {
5050
return this.inventory;
5151
}
5252

5353
/**
5454
* Sets a complete inventory object
5555
* @param inventory Sets the specific inventory in the loadout
56-
* @return Loadout
56+
* @return Returns the loadout
5757
*/
5858
public Loadout setInventory(Inventory inventory) {
5959
this.inventory = inventory;
@@ -62,9 +62,19 @@ public Loadout setInventory(Inventory inventory) {
6262

6363
/**
6464
* Return the assoicated statistic object
65-
* @return Returns the staticis
65+
* @return Returns the statistic
6666
*/
6767
public Statistic getStatistic() {
6868
return this.statistic;
6969
}
70+
71+
/**
72+
* Sets a statistic object
73+
* @param stats
74+
* @return Returns the Loadout
75+
*/
76+
public Loadout setStatistic(Statistic stats) {
77+
this.statistic = stats;
78+
return this;
79+
}
7080
}

src/main/java/at/droll/div2builder/core/item/weapon/Weapon.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package at.droll.div2builder.core.item.weapon;
22

3-
import java.io.Serializable;
43
import java.util.Arrays;
54
import java.util.HashMap;
65
import java.util.List;

src/main/java/at/droll/div2builder/core/statistic/Statistic.java

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

src/main/java/at/droll/div2builder/frontend/App.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
import javafx.scene.Scene;
77
import javafx.scene.image.Image;
88
import javafx.stage.Stage;
9-
109
import java.io.IOException;
11-
import java.util.Locale;
12-
import java.util.ResourceBundle;
1310

1411
/**
1512
* div2builder frontend based upon JavaFX

0 commit comments

Comments
 (0)