use of pcgen.core.SpellProhibitor in project pcgen by PCGen.
the class ProhibitedListToken method getProhibitedListToken.
public static String getProhibitedListToken(String tokenSource, CharacterDisplay display) {
int k = tokenSource.lastIndexOf(',');
String jointext;
if (k >= 0) {
jointext = tokenSource.substring(k + 1);
} else {
jointext = ",";
}
Set<String> set = new TreeSet<>();
for (PCClass pcClass : display.getClassSet()) {
if (display.getLevel(pcClass) > 0) {
for (SpellProhibitor sp : pcClass.getSafeListFor(ListKey.PROHIBITED_SPELLS)) {
set.addAll(sp.getValueList());
}
Collection<? extends SpellProhibitor> prohibList = display.getProhibitedSchools(pcClass);
if (prohibList != null) {
for (SpellProhibitor sp : prohibList) {
set.addAll(sp.getValueList());
}
}
}
}
return StringUtil.join(set, jointext);
}
use of pcgen.core.SpellProhibitor in project pcgen by PCGen.
the class ProhibitspellTokenTest method testUnparseLegalSubSchool.
@Test
public void testUnparseLegalSubSchool() throws PersistenceLayerException {
SpellProhibitor o = getConstant(ProhibitedSpellType.SUBSCHOOL, "Elementary");
primaryProf.addToListFor(getListKey(), o);
expectSingle(getToken().unparse(primaryContext, primaryProf), "SUBSCHOOL.Elementary");
}
use of pcgen.core.SpellProhibitor in project pcgen by PCGen.
the class ChoiceTokenTest method testUnparseLegalSubSchool.
@Test
public void testUnparseLegalSubSchool() throws PersistenceLayerException {
SpellProhibitor o = getConstant(ProhibitedSpellType.SUBSCHOOL, "Elementary");
primaryProf.put(getObjectKey(), o);
expectSingle(getToken().unparse(primaryContext, primaryProf), "SUBSCHOOL|Elementary");
}
use of pcgen.core.SpellProhibitor in project pcgen by PCGen.
the class ChoiceTokenTest method testUnparseLegalDescriptor.
@Test
public void testUnparseLegalDescriptor() throws PersistenceLayerException {
SpellProhibitor o = getConstant(ProhibitedSpellType.DESCRIPTOR, "Fire");
primaryProf.put(getObjectKey(), o);
expectSingle(getToken().unparse(primaryContext, primaryProf), "DESCRIPTOR|Fire");
}
use of pcgen.core.SpellProhibitor in project pcgen by PCGen.
the class ProhibitedToken method unparse.
@Override
public String[] unparse(LoadContext context, PCClass pcc) {
Changes<SpellProhibitor> changes = context.getObjectContext().getListChanges(pcc, ListKey.PROHIBITED_SPELLS);
Collection<SpellProhibitor> added = changes.getAdded();
if (added == null || added.isEmpty()) {
// Zero indicates no Token present
return null;
}
Set<String> set = new TreeSet<>();
for (SpellProhibitor sp : added) {
set.addAll(sp.getValueList());
}
return new String[] { StringUtil.join(set, Constants.COMMA) };
}
Aggregations