use of pcgen.cdom.inst.EqSizePenalty in project pcgen by PCGen.
the class Equipment method bonusTo.
/**
* Add bonuses
*
* @param aPC
* The PC that has this Equipment
* @param aType
* The type of the Bonus
* @param aName
* The name of the Bonus
* @param anObj
* An object used in the bonus calculations, should be a
* PC or a piece of Equipment.
* @param bPrimary
* If true get bonuses for primary head
* @return bonus
*/
private double bonusTo(final PlayerCharacter aPC, final String aType, final String aName, final Object anObj, final boolean bPrimary) {
StringBuilder sB = new StringBuilder(aType.toUpperCase());
sB.append('.');
sB.append(aName.toUpperCase());
sB.append('.');
final String aBonusKey = sB.toString();
// entries that deal with this bonus request
for (String aKey : getBonusMap().keySet()) {
if (aKey.startsWith(aBonusKey)) {
putBonusMap(aKey, "0");
}
}
bonusPrimary = bPrimary;
if (bPrimary) {
BonusCalc.equipBonusTo(this, aType, aName, aPC);
// now do temp bonuses
final List<BonusObj> tbList = new ArrayList<>();
for (BonusObj aBonus : getTempBonusList()) {
if (!tbList.contains(aBonus)) {
tbList.add(aBonus);
}
}
BonusCalc.bonusTo(this, aType, aName, anObj, tbList, aPC);
}
// If using 3.5 weapon penalties, add them in also
if (Globals.checkRule(RuleConstants.SYS_35WP)) {
for (EqSizePenalty esp : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(EqSizePenalty.class)) {
BonusCalc.bonusTo(this, aType, aName, this, esp.getBonuses(), aPC);
}
}
final List<EquipmentModifier> eqModList = getEqModifierList(bPrimary);
for (EquipmentModifier eqMod : eqModList) {
eqMod.bonusTo(aPC, aType, aName, this);
}
double iBonus = 0;
for (String key : getBonusMap().keySet()) {
if (key.startsWith(aBonusKey)) {
iBonus += Float.parseFloat(getBonusMap().get(key));
}
}
return iBonus;
}
Aggregations