Search in sources :

Example 1 with BonusContainer

use of pcgen.cdom.base.BonusContainer in project pcgen by PCGen.

the class BonusManager method getAllActiveBonuses.

private Map<BonusObj, Object> getAllActiveBonuses() {
    Map<BonusObj, Object> ret = new IdentityHashMap<>();
    for (final BonusContainer pobj : pc.getBonusContainerList()) {
        // the equipment they belong to.
        if (pobj != null && !(pobj instanceof EquipmentModifier)) {
            boolean use = true;
            if (pobj instanceof PCClass) {
                // Class bonuses are only included if the level is greater
                // than 0
                // This is because 0 levels of a class can be added to
                // access spell casting etc
                use = pc.getLevel(((PCClass) pobj)) > 0;
            }
            if (use) {
                pobj.activateBonuses(pc);
                List<BonusObj> abs = pobj.getActiveBonuses(pc);
                for (BonusObj bo : abs) {
                    ret.put(bo, pobj);
                }
            }
        }
    }
    if (pc.getUseTempMods()) {
        ret.putAll(getTempBonuses());
    }
    return ret;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) IdentityHashMap(java.util.IdentityHashMap) CDOMObject(pcgen.cdom.base.CDOMObject) MissingObject(pcgen.core.bonus.util.MissingObject) BonusContainer(pcgen.cdom.base.BonusContainer)

Aggregations

IdentityHashMap (java.util.IdentityHashMap)1 BonusContainer (pcgen.cdom.base.BonusContainer)1 CDOMObject (pcgen.cdom.base.CDOMObject)1 BonusObj (pcgen.core.bonus.BonusObj)1 MissingObject (pcgen.core.bonus.util.MissingObject)1