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