Search in sources :

Example 11 with SpellProhibitor

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);
}
Also used : TreeSet(java.util.TreeSet) PCClass(pcgen.core.PCClass) SpellProhibitor(pcgen.core.SpellProhibitor)

Example 12 with SpellProhibitor

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");
}
Also used : SpellProhibitor(pcgen.core.SpellProhibitor) Test(org.junit.Test)

Example 13 with SpellProhibitor

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");
}
Also used : SpellProhibitor(pcgen.core.SpellProhibitor) Test(org.junit.Test)

Example 14 with SpellProhibitor

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");
}
Also used : SpellProhibitor(pcgen.core.SpellProhibitor) Test(org.junit.Test)

Example 15 with SpellProhibitor

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) };
}
Also used : TreeSet(java.util.TreeSet) SpellProhibitor(pcgen.core.SpellProhibitor)

Aggregations

SpellProhibitor (pcgen.core.SpellProhibitor)22 TreeSet (java.util.TreeSet)6 Test (org.junit.Test)6 PCClass (pcgen.core.PCClass)6 StringTokenizer (java.util.StringTokenizer)4 ProhibitedSpellType (pcgen.util.enumeration.ProhibitedSpellType)4 ArrayList (java.util.ArrayList)2 SubClass (pcgen.core.SubClass)2 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)2 CharID (pcgen.cdom.enumeration.CharID)1 PCClassLevel (pcgen.cdom.inst.PCClassLevel)1 Domain (pcgen.core.Domain)1 SpecialAbility (pcgen.core.SpecialAbility)1 SpellSupportForPCClass (pcgen.core.SpellSupportForPCClass)1 BonusObj (pcgen.core.bonus.BonusObj)1 CDOMChooserFacadeImpl (pcgen.core.chooser.CDOMChooserFacadeImpl)1 PCLevelInfoStat (pcgen.core.pclevelinfo.PCLevelInfoStat)1 Prerequisite (pcgen.core.prereq.Prerequisite)1 Gui2InfoFactory (pcgen.gui2.facade.Gui2InfoFactory)1 HtmlInfoBuilder (pcgen.gui2.util.HtmlInfoBuilder)1