Search in sources :

Example 16 with SpellProhibitor

use of pcgen.core.SpellProhibitor in project pcgen by PCGen.

the class ProhibitspellToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, PCClass pcc, String value) {
    SpellProhibitor sp = subParse(value);
    if (sp == null) {
        return ParseResult.INTERNAL_ERROR;
    }
    context.getObjectContext().addToList(pcc, ListKey.SPELL_PROHIBITOR, sp);
    return ParseResult.SUCCESS;
}
Also used : SpellProhibitor(pcgen.core.SpellProhibitor)

Example 17 with SpellProhibitor

use of pcgen.core.SpellProhibitor in project pcgen by PCGen.

the class ProhibitspellTokenTest method getConstant.

private static SpellProhibitor getConstant(ProhibitedSpellType type, String args) {
    SpellProhibitor spellProb = new SpellProhibitor();
    spellProb.setType(type);
    spellProb.addValue(args);
    return spellProb;
}
Also used : SpellProhibitor(pcgen.core.SpellProhibitor)

Example 18 with SpellProhibitor

use of pcgen.core.SpellProhibitor in project pcgen by PCGen.

the class ProhibitspellTokenTest method testUnparseLegalDescriptor.

@Test
public void testUnparseLegalDescriptor() throws PersistenceLayerException {
    SpellProhibitor o = getConstant(ProhibitedSpellType.DESCRIPTOR, "Fire");
    primaryProf.addToListFor(getListKey(), o);
    expectSingle(getToken().unparse(primaryContext, primaryProf), "DESCRIPTOR.Fire");
}
Also used : SpellProhibitor(pcgen.core.SpellProhibitor) Test(org.junit.Test)

Example 19 with SpellProhibitor

use of pcgen.core.SpellProhibitor in project pcgen by PCGen.

the class ProhibitspellTokenTest method testUnparseLegalSchool.

@Test
public void testUnparseLegalSchool() throws PersistenceLayerException {
    SpellProhibitor o = getConstant(ProhibitedSpellType.SCHOOL, "Public");
    primaryProf.addToListFor(getListKey(), o);
    expectSingle(getToken().unparse(primaryContext, primaryProf), "SCHOOL.Public");
}
Also used : SpellProhibitor(pcgen.core.SpellProhibitor) Test(org.junit.Test)

Example 20 with SpellProhibitor

use of pcgen.core.SpellProhibitor in project pcgen by PCGen.

the class SpellSupportFacadeImpl method getClassInfo.

/**
	 * @see pcgen.core.facade.SpellSupportFacade#getClassInfo(pcgen.core.facade.ClassFacade)
	 */
@Override
public String getClassInfo(ClassFacade spellcaster) {
    if (!(spellcaster instanceof PCClass)) {
        return "";
    }
    PCClass aClass = (PCClass) spellcaster;
    SpellSupportForPCClass spellSupport = pc.getSpellSupport(aClass);
    int highestSpellLevel = spellSupport.getHighestLevelSpell(pc);
    final HtmlInfoBuilder b = new HtmlInfoBuilder();
    //$NON-NLS-1$
    b.append("<table border=1><tr><td><font size=-2><b>");
    //$NON-NLS-1$
    b.append(OutputNameFormatting.piString(aClass, false)).append(" [");
    b.append(String.valueOf(charDisplay.getLevel(aClass) + //$NON-NLS-1$
    (int) pc.getTotalBonusTo("PCLEVEL", aClass.getKeyName())));
    //$NON-NLS-1$
    b.append("]</b></font></td>");
    for (int i = 0; i <= highestSpellLevel; ++i) {
        //$NON-NLS-1$
        b.append("<td><font size=-2><b><center>&nbsp;");
        b.append(String.valueOf(i));
        //$NON-NLS-1$
        b.append("&nbsp;</b></center></font></td>");
    }
    //$NON-NLS-1$
    b.append("</tr>");
    //$NON-NLS-1$
    b.append("<tr><td><font size=-1><b>Cast</b></font></td>");
    for (int i = 0; i <= highestSpellLevel; ++i) {
        //$NON-NLS-1$
        b.append("<td><font size=-1><center>");
        b.append(getNumCast(aClass, i, pc));
        //$NON-NLS-1$
        b.append("</center></font></td>");
    }
    //$NON-NLS-1$
    b.append("</tr>");
    // Making sure KnownList can be handled safely and produces the correct behaviour
    if (spellSupport.hasKnownList() || spellSupport.hasKnownSpells(pc)) {
        //$NON-NLS-1$
        b.append("<tr><td><font size=-1><b>Known</b></font></td>");
        for (int i = 0; i <= highestSpellLevel; ++i) {
            final int a = spellSupport.getKnownForLevel(i, pc);
            final int bonus = spellSupport.getSpecialtyKnownForLevel(i, pc);
            //$NON-NLS-1$
            b.append("<td><font size=-1><center>");
            b.append(String.valueOf(a));
            if (bonus > 0) {
                b.append('+').append(Integer.toString(bonus));
            }
            //$NON-NLS-1$
            b.append("</center></font></td>");
        }
        //$NON-NLS-1$
        b.append("</tr>");
    }
    //$NON-NLS-1$
    b.append("<tr><td><font size=-1><b>DC</b></font></td>");
    for (int i = 0; i <= highestSpellLevel; ++i) {
        //$NON-NLS-1$
        b.append("<td><font size=-1><center>");
        b.append(String.valueOf(getDC(aClass, i, pc)));
        //$NON-NLS-1$
        b.append("</center></font></td>");
    }
    //$NON-NLS-1$
    b.append("</tr></table>");
    //$NON-NLS-1$
    b.appendI18nElement("InfoSpells.caster.type", aClass.getSpellType());
    b.appendLineBreak();
    //$NON-NLS-1$ 
    b.appendI18nElement("InfoSpells.stat.bonus", aClass.getSpellBaseStat());
    if (pc.hasAssocs(aClass, AssociationKey.SPECIALTY) || charDisplay.hasDomains()) {
        boolean needComma = false;
        StringBuilder schoolInfo = new StringBuilder();
        String spec = pc.getAssoc(aClass, AssociationKey.SPECIALTY);
        if (spec != null) {
            schoolInfo.append(spec);
            needComma = true;
        }
        for (Domain d : charDisplay.getSortedDomainSet()) {
            if (needComma) {
                schoolInfo.append(',');
            }
            needComma = true;
            schoolInfo.append(d.getKeyName());
        }
        b.appendLineBreak();
        //$NON-NLS-1$ 
        b.appendI18nElement("InfoSpells.school", schoolInfo.toString());
    }
    Set<String> set = new TreeSet<>();
    for (SpellProhibitor sp : aClass.getSafeListFor(ListKey.PROHIBITED_SPELLS)) {
        set.addAll(sp.getValueList());
    }
    Collection<? extends SpellProhibitor> prohibList = charDisplay.getProhibitedSchools(aClass);
    if (prohibList != null) {
        for (SpellProhibitor sp : prohibList) {
            set.addAll(sp.getValueList());
        }
    }
    if (!set.isEmpty()) {
        b.appendLineBreak();
        //$NON-NLS-1$ 
        b.appendI18nElement(//$NON-NLS-1$ 
        "InfoSpells.prohibited.school", //$NON-NLS-1$ 
        StringUtil.join(set, ","));
    }
    String bString = SourceFormat.getFormattedString(aClass, Globals.getSourceDisplay(), true);
    if (bString.length() > 0) {
        b.appendLineBreak();
        //$NON-NLS-1$ 
        b.appendI18nElement("in_source", bString);
    }
    return b.toString();
}
Also used : TreeSet(java.util.TreeSet) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) PCClass(pcgen.core.PCClass) SpellSupportForPCClass(pcgen.core.SpellSupportForPCClass) Domain(pcgen.core.Domain) SpellSupportForPCClass(pcgen.core.SpellSupportForPCClass) 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