Search in sources :

Example 71 with BonusObj

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

the class MonNonSkillTHDTokenTest method testUnparseOnePrereq.

@Test
public void testUnparseOnePrereq() throws PersistenceLayerException {
    BonusObj bonus = getBonus(1);
    PreParserFactory prereqParser = PreParserFactory.getInstance();
    Prerequisite prereq = prereqParser.parse("PRERACE:1,Dwarf");
    assertNotNull(prereq);
    bonus.addPrerequisite(prereq);
    primaryProf.addToListFor(ListKey.BONUS, bonus);
    String[] sap = getToken().unparse(primaryContext, primaryProf);
    expectSingle(sap, "1|PRERACE:1,Dwarf");
}
Also used : PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) BonusObj(pcgen.core.bonus.BonusObj) Prerequisite(pcgen.core.prereq.Prerequisite) Test(org.junit.Test)

Example 72 with BonusObj

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

the class MonNonSkillTHDTokenTest method getBonus.

private BonusObj getBonus(int bonusValue) {
    BonusObj bon = Bonus.newBonus(primaryContext, "MONNONSKILLHD|NUMBER|" + bonusValue);
    assertNotNull(bon);
    bon.setTokenSource(token.getTokenName());
    return bon;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj)

Example 73 with BonusObj

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

the class BonusToken method unparse.

@Override
public String[] unparse(LoadContext context, EqSizePenalty esp) {
    Collection<BonusObj> added = esp.getBonuses();
    String tokenName = getTokenName();
    Set<String> bonusSet = new TreeSet<>();
    for (BonusObj bonus : added) {
        if (tokenName.equals(bonus.getTokenSource())) {
            bonusSet.add(bonus.toString());
        }
    }
    if (bonusSet.isEmpty()) {
        // This is okay - just no BONUSes from this token
        return null;
    }
    return bonusSet.toArray(new String[bonusSet.size()]);
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) TreeSet(java.util.TreeSet)

Example 74 with BonusObj

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

the class StartFeatsTokenTest method getBonus.

private BonusObj getBonus(int bonusValue) throws PersistenceLayerException {
    BonusObj bon = Bonus.newBonus(primaryContext, "FEAT|POOL|" + bonusValue);
    assertNotNull(bon);
    PreParserFactory prereqParser = PreParserFactory.getInstance();
    Prerequisite prereq = prereqParser.parse("PREMULT:1,[PREHD:MIN=1],[PRELEVEL:MIN=1]");
    assertNotNull(prereq);
    bon.addPrerequisite(prereq);
    bon.setTokenSource(token.getTokenName());
    return bon;
}
Also used : PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) BonusObj(pcgen.core.bonus.BonusObj) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 75 with BonusObj

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

the class Equipment method getActiveBonuses.

/**
	 * returns all BonusObj's that are "active"
	 * 
	 * @param aPC
	 *            PlayerCharacter used to check prereqs for bonuses
	 * @return active bonuses
	 */
@Override
public List<BonusObj> getActiveBonuses(final PlayerCharacter aPC) {
    final List<BonusObj> aList = new ArrayList<>();
    for (BonusObj bonus : getRawBonusList(aPC)) {
        if (aPC.isApplied(bonus)) {
            aList.add(bonus);
        }
    }
    List<EquipmentModifier> eqModList = getEqModifierList(true);
    for (EquipmentModifier eqMod : eqModList) {
        aList.addAll(eqMod.getActiveBonuses(this, aPC));
    }
    eqModList = getEqModifierList(false);
    for (EquipmentModifier eqMod : eqModList) {
        aList.addAll(eqMod.getActiveBonuses(this, aPC));
    }
    return aList;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) ArrayList(java.util.ArrayList)

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