MCPcopy Create free account
hub / github.com/PCGen/pcgen / addItemCosts

Method addItemCosts

code/src/java/pcgen/core/analysis/EqModCost.java:49–94  ·  view source on GitHub ↗
(EquipmentModifier eqMod, final PlayerCharacter aPC, final String bonusType,
		final int qty, final Equipment parent)

Source from the content-addressed store, hash-verified

47 }
48
49 public static BigDecimal addItemCosts(EquipmentModifier eqMod, final PlayerCharacter aPC, final String bonusType,
50 final int qty, final Equipment parent)
51 {
52 double val = 0;
53
54 Set<String> typesToGetBonusesFor = new HashSet<>();
55
56 for (BonusObj bonus : eqMod.getBonusList(parent))
57 {
58 boolean meetsAll = true;
59
60 if (bonus.getBonusName().equals(bonusType))
61 {
62 StringTokenizer aTok = new StringTokenizer(bonus.toString().substring(bonusType.length()), "|", false);
63 final String bType = aTok.nextToken();
64 aTok = new StringTokenizer(bType.substring(5), ".", false);
65
66 StringBuilder typeString = new StringBuilder("TYPE");
67
68 while (aTok.hasMoreTokens())
69 {
70 final String sub_type = aTok.nextToken();
71 meetsAll = parent.isType(sub_type);
72
73 if (!meetsAll)
74 {
75 break;
76 }
77
78 typeString.append(".").append(sub_type);
79 }
80
81 if (meetsAll)
82 {
83 typesToGetBonusesFor.add(typeString.toString());
84 }
85 }
86 }
87
88 for (String typeString : typesToGetBonusesFor)
89 {
90 val += eqMod.bonusTo(aPC, bonusType, typeString, parent);
91 }
92
93 return BigDecimal.valueOf(val * qty);
94 }
95
96 public static boolean getCostDouble(EquipmentModifier eqMod)
97 {

Callers 1

Calls 11

nextTokenMethod · 0.80
hasMoreTokensMethod · 0.80
equalsMethod · 0.65
toStringMethod · 0.65
isTypeMethod · 0.65
addMethod · 0.65
getBonusListMethod · 0.45
getBonusNameMethod · 0.45
appendMethod · 0.45
bonusToMethod · 0.45
valueOfMethod · 0.45

Tested by

no test coverage detected