Search in sources :

Example 26 with BonusObj

use of pcgen.core.bonus.BonusObj in project pcgen by PCGen.

the class CheckBonusFacet method getCheckBonusTo.

/**
	 * Returns the Bonus value provided solely by Checks, for a given Bonus type
	 * and Bonus name on the Player Character identified by the given CharID.
	 * 
	 * @param id
	 *            CharId identifying the Player Character for which the Bonus
	 *            value will be returned
	 * @param type
	 *            The Bonus type for which the Bonus value will be returned
	 * @param name
	 *            The Bonus name for which the Bonus value will be returned
	 * @return The Bonus value provided solely by Checks, for a given Bonus type
	 *         and Bonus name on the Player Character identified by the given
	 *         CharID
	 * @deprecated by STATMODSAVE Code Control
	 */
@Deprecated
public double getCheckBonusTo(CharID id, String type, String name) {
    double bonus = 0;
    String upperType = type.toUpperCase();
    String upperName = name.toUpperCase();
    for (PCCheck check : checkFacet.getSet(id)) {
        List<BonusObj> tempList = BonusUtilities.getBonusFromList(check.getListFor(ListKey.BONUS), upperType, upperName);
        if (!tempList.isEmpty()) {
            bonus += bonusCheckingFacet.getAllBonusValues(id, tempList, check.getQualifiedKey());
        }
    }
    return bonus;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) PCCheck(pcgen.core.PCCheck)

Example 27 with BonusObj

use of pcgen.core.bonus.BonusObj in project pcgen by PCGen.

the class PCLevelInfo method getBonusSkillPool.

/**
	 * Calculate the number of bonus skill points added by this level.
	 *
	 * @return  the number of bonus skill points added by this level
	 */
private int getBonusSkillPool(PlayerCharacter aPC) {
    int returnValue = 0;
    final PCClass aClass = aPC.getClassKeyed(classKeyName);
    final String purchaseName = SettingsHandler.getGame().getPurchaseModeMethodName();
    if (purchaseName != null) {
        PointBuyMethod pbm = SettingsHandler.getGame().getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PointBuyMethod.class, purchaseName);
        List<BonusObj> bonusList = BonusUtilities.getBonusFromList(pbm.getBonuses(), "SKILLPOOL", "NUMBER");
        returnValue += (int) aPC.calcBonusFromList(bonusList, null);
    }
    if (aClass != null) {
        // These bonuses apply to the level or higher. We have to add and then remove
        // the previous to get the effective level bonus
        returnValue += (int) aClass.getBonusTo("SKILLPOOL", "NUMBER", classLevel, aPC);
        returnValue -= (int) aClass.getBonusTo("SKILLPOOL", "NUMBER", classLevel - 1, aPC);
    }
    if (classLevel == 1) {
        returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "CLASS." + classKeyName);
    }
    returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "CLASS." + classKeyName + ";LEVEL." + Integer.toString(classLevel));
    returnValue += (int) aPC.getTotalBonusTo("SKILLPOOL", "LEVEL." + aPC.getCharacterLevel(this));
    return returnValue;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) PointBuyMethod(pcgen.core.PointBuyMethod) PCClass(pcgen.core.PCClass)

Example 28 with BonusObj

use of pcgen.core.bonus.BonusObj in project pcgen by PCGen.

the class PlayerCharacter method getPObjectWithCostBonusTo.

/**
	 * Returns a bonus.
	 *
	 * @param aList
	 * @param aType
	 * @param aName
	 * @return double
	 */
private double getPObjectWithCostBonusTo(final Collection<? extends CDOMObject> aList, final String aType, final String aName) {
    double iBonus = 0;
    if (aList.isEmpty()) {
        return iBonus;
    }
    for (CDOMObject anObj : aList) {
        final List<BonusObj> tempList = BonusUtilities.getBonusFromList(anObj.getBonusList(this), aType, aName);
        iBonus += calcBonusWithCostFromList(tempList);
    }
    return iBonus;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) CDOMObject(pcgen.cdom.base.CDOMObject)

Example 29 with BonusObj

use of pcgen.core.bonus.BonusObj in project pcgen by PCGen.

the class BonusActivation method activateBonuses.

public static void activateBonuses(CDOMObject po, PlayerCharacter aPC) {
    for (Iterator<BonusObj> ab = po.getRawBonusList(aPC).iterator(); ab.hasNext(); ) {
        final BonusObj aBonus = ab.next();
        aPC.setApplied(aBonus, aBonus.qualifies(aPC, po));
    }
}
Also used : BonusObj(pcgen.core.bonus.BonusObj)

Example 30 with BonusObj

use of pcgen.core.bonus.BonusObj in project pcgen by PCGen.

the class TempBonusHelper method removeBonusFromCharacter.

static void removeBonusFromCharacter(PlayerCharacter pc, Equipment aEq, CDOMObject aCreator) {
    for (Map.Entry<BonusObj, BonusManager.TempBonusInfo> me : pc.getTempBonusMap().entrySet()) {
        BonusObj aBonus = me.getKey();
        TempBonusInfo tbi = me.getValue();
        Object aC = tbi.source;
        if (aCreator != aC) {
            continue;
        }
        Object aT = tbi.target;
        if ((aT instanceof Equipment) && (aEq != null)) {
            if (aEq.equals(aT)) {
                pc.removeTempBonus(aBonus);
                pc.removeTempBonusItemList((Equipment) aT);
                ((Equipment) aT).removeTempBonus(aBonus);
                ((Equipment) aT).setAppliedName(EMPTY_STRING);
            }
        } else if ((aT instanceof PlayerCharacter) && (aEq == null)) {
            pc.removeTempBonus(aBonus);
        }
    }
}
Also used : TempBonusInfo(pcgen.core.BonusManager.TempBonusInfo) PlayerCharacter(pcgen.core.PlayerCharacter) BonusObj(pcgen.core.bonus.BonusObj) Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject) Map(java.util.Map)

Aggregations

BonusObj (pcgen.core.bonus.BonusObj)126 LoadContext (pcgen.rules.context.LoadContext)48 PlayerCharacter (pcgen.core.PlayerCharacter)29 ArrayList (java.util.ArrayList)22 CDOMObject (pcgen.cdom.base.CDOMObject)18 PCClass (pcgen.core.PCClass)14 Prerequisite (pcgen.core.prereq.Prerequisite)13 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)13 EquipSet (pcgen.core.character.EquipSet)11 IdentityHashMap (java.util.IdentityHashMap)10 Map (java.util.Map)10 TreeSet (java.util.TreeSet)10 Ability (pcgen.core.Ability)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)8 TempBonusInfo (pcgen.core.BonusManager.TempBonusInfo)8 Equipment (pcgen.core.Equipment)8 HashMap (java.util.HashMap)7 Race (pcgen.core.Race)7 StringTokenizer (java.util.StringTokenizer)6 CNAbility (pcgen.cdom.content.CNAbility)6