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");
}
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;
}
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()]);
}
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;
}
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;
}
Aggregations