Search in sources :

Example 76 with PCClass

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

the class FavoredListToken method getFavoredListToken.

/**
	 * Retrieve the list of favored classes for the PC.
	 * @param display The character to be queried.
	 * @return The text comma seperated list of favored classes.
	 */
public static String getFavoredListToken(CharacterDisplay display) {
    if (display.hasAnyFavoredClass()) {
        return "Any";
    }
    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (PCClass pcc : display.getFavoredClasses()) {
        if (!first) {
            sb.append(", ");
        }
        sb.append(pcc.getFullKey());
    }
    return sb.toString();
}
Also used : PCClass(pcgen.core.PCClass)

Example 77 with PCClass

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

the class ExchangelevelToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, PCClass pcc, String value) {
    final StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
    if (tok.countTokens() != 4) {
        return new ParseResult.Fail(getTokenName() + " must have 4 | delimited arguments : " + value, context);
    }
    String classString = tok.nextToken();
    CDOMSingleRef<PCClass> cl = context.getReferenceContext().getCDOMReference(PCClass.class, classString);
    String mindlString = tok.nextToken();
    int mindl;
    try {
        mindl = Integer.parseInt(mindlString);
    } catch (NumberFormatException nfe) {
        return new ParseResult.Fail(getTokenName() + " expected an integer: " + mindlString, context);
    }
    String maxdlString = tok.nextToken();
    int maxdl;
    try {
        maxdl = Integer.parseInt(maxdlString);
    } catch (NumberFormatException nfe) {
        return new ParseResult.Fail(getTokenName() + " expected an integer: " + maxdlString, context);
    }
    String minremString = tok.nextToken();
    int minrem;
    try {
        minrem = Integer.parseInt(minremString);
    } catch (NumberFormatException nfe) {
        return new ParseResult.Fail(getTokenName() + " expected an integer: " + minremString, context);
    }
    try {
        LevelExchange le = new LevelExchange(cl, mindl, maxdl, minrem);
        context.getObjectContext().put(pcc, ObjectKey.EXCHANGE_LEVEL, le);
        return ParseResult.SUCCESS;
    } catch (IllegalArgumentException e) {
        ComplexParseResult pr = new ComplexParseResult();
        pr.addErrorMessage("Error in " + getTokenName() + ' ' + e.getMessage());
        pr.addErrorMessage("  Token contents: " + value);
        return pr;
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) ComplexParseResult(pcgen.rules.persistence.token.ComplexParseResult) ParseResult(pcgen.rules.persistence.token.ParseResult) LevelExchange(pcgen.cdom.content.LevelExchange) ComplexParseResult(pcgen.rules.persistence.token.ComplexParseResult) PCClass(pcgen.core.PCClass)

Example 78 with PCClass

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

the class PreSubClassTester method passes.

/**
	 * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter)
	 */
@Override
public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source) throws PrerequisiteException {
    int runningTotal = 0;
    int num;
    try {
        // number we must match
        num = Integer.parseInt(prereq.getOperand());
    } catch (NumberFormatException nfe) {
        throw new PrerequisiteException(LanguageBundle.getFormattedString("PreSubClass.error.badly_formed", //$NON-NLS-1$
        prereq.toString()));
    }
    final String thisClass = prereq.getKey();
    for (PCClass aClass : display.getClassSet()) {
        final String subClassName = display.getSubClassName(aClass);
        if (subClassName != null && !subClassName.isEmpty()) {
            if (thisClass.equalsIgnoreCase(subClassName)) {
                runningTotal++;
                break;
            }
        }
    }
    runningTotal = prereq.getOperator().compare(runningTotal, num);
    return countedTotal(prereq, runningTotal);
}
Also used : PrerequisiteException(pcgen.core.prereq.PrerequisiteException) PCClass(pcgen.core.PCClass)

Example 79 with PCClass

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

the class PreSpellCastMemorizeTester method passes.

/**
	 * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.prereq.Prerequisite, pcgen.core.PlayerCharacter)
	 */
@Override
public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source) {
    final int requiredNumber = Integer.parseInt(prereq.getOperand());
    final boolean prereqMemorized = //$NON-NLS-1$
    prereq.getKey().toUpperCase().startsWith("Y");
    int runningTotal = 0;
    for (PCClass aClass : display.getClassSet()) {
        if (aClass.getSafe(ObjectKey.MEMORIZE_SPELLS) == prereqMemorized) {
            runningTotal++;
        }
    }
    runningTotal = prereq.getOperator().compare(runningTotal, requiredNumber);
    return countedTotal(prereq, runningTotal);
}
Also used : PCClass(pcgen.core.PCClass)

Example 80 with PCClass

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

the class PreSpellCastTester method passes.

/**
	 * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter)
	 */
@Override
public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source) {
    final int requiredNumber = Integer.parseInt(prereq.getOperand());
    final String prereqSpellType = prereq.getKey();
    int runningTotal = 0;
    for (PCClass aClass : display.getClassSet()) {
        if (prereqSpellType.equalsIgnoreCase(aClass.getSpellType())) {
            runningTotal++;
        }
    }
    runningTotal = prereq.getOperator().compare(runningTotal, requiredNumber);
    return countedTotal(prereq, runningTotal);
}
Also used : PCClass(pcgen.core.PCClass)

Aggregations

PCClass (pcgen.core.PCClass)359 Test (org.junit.Test)96 PlayerCharacter (pcgen.core.PlayerCharacter)61 Skill (pcgen.core.Skill)55 ArrayList (java.util.ArrayList)35 Domain (pcgen.core.Domain)30 LoadContext (pcgen.rules.context.LoadContext)28 PCClassLevel (pcgen.cdom.inst.PCClassLevel)26 CDOMObject (pcgen.cdom.base.CDOMObject)23 CharacterSpell (pcgen.core.character.CharacterSpell)20 Spell (pcgen.core.spell.Spell)20 StringTokenizer (java.util.StringTokenizer)19 CharID (pcgen.cdom.enumeration.CharID)19 ClassSource (pcgen.cdom.helper.ClassSource)19 PreClassTester (plugin.pretokens.test.PreClassTester)16 SkillCost (pcgen.cdom.enumeration.SkillCost)15 ParseResult (pcgen.rules.persistence.token.ParseResult)15 Ability (pcgen.core.Ability)14 Race (pcgen.core.Race)14 BonusObj (pcgen.core.bonus.BonusObj)14