use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class SpellListMemorizeToken method getToken.
/**
* @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
*/
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
StringBuilder retValue = new StringBuilder();
SpellListTokenParams params = new SpellListTokenParams(tokenSource, SpellListToken.SPELLTAG_MEMORIZE);
final CDOMObject aObject = pc.getSpellClassAtIndex(params.getClassNum());
if (aObject != null) {
PCClass aClass = null;
if (aObject instanceof PCClass) {
aClass = (PCClass) aObject;
}
if (aClass != null) {
retValue.append((boolean) aClass.getSafe(ObjectKey.MEMORIZE_SPELLS));
}
}
return retValue.toString();
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class SpellListTypeToken method getToken.
/**
* @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
*/
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
StringBuilder retValue = new StringBuilder();
SpellListTokenParams params = new SpellListTokenParams(tokenSource, SpellListToken.SPELLTAG_TYPE);
final CDOMObject aObject = pc.getSpellClassAtIndex(params.getClassNum());
if (aObject != null) {
PCClass aClass = null;
if (aObject instanceof PCClass) {
aClass = (PCClass) aObject;
}
if (aClass != null) {
retValue.append(aClass.getSpellType());
}
}
return retValue.toString();
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class SpellListCastToken method getToken.
/**
* @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
*/
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
StringBuilder retValue = new StringBuilder();
SpellListTokenParams params = new SpellListTokenParams(tokenSource, SpellListToken.SPELLTAG_CAST);
final CDOMObject aObject = pc.getSpellClassAtIndex(params.getClassNum());
if (aObject != null) {
retValue.append(getCastNum(aObject, params.getLevel(), pc));
}
return retValue.toString();
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class SpellListDcStatToken method getToken.
/**
* @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler)
*/
@Override
public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
StringBuilder retValue = new StringBuilder();
SpellListTokenParams params = new SpellListTokenParams(tokenSource, SpellListToken.SPELLTAG_DCSTAT);
final CDOMObject aObject = pc.getSpellClassAtIndex(params.getClassNum());
if (aObject != null) {
PCClass aClass = null;
if (aObject instanceof PCClass) {
aClass = (PCClass) aObject;
}
if (aClass != null) {
retValue.append(aClass.getSpellBaseStat());
}
}
return retValue.toString();
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class PreFactTester method passes.
/**
* @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter)
*/
@Override
public int passes(final Prerequisite prereq, final PlayerCharacter aPC, CDOMObject source) throws PrerequisiteException {
final int number;
try {
number = Integer.parseInt(prereq.getOperand());
} catch (NumberFormatException exceptn) {
throw new PrerequisiteException(LanguageBundle.getFormattedString("PreFact.error", //$NON-NLS-1$
prereq.toString()));
}
String location = prereq.getCategoryName();
String[] locationElements = location.split("\\.");
Iterable<Reducible> objModel = (Iterable<Reducible>) OutputDB.getIterable(aPC.getCharID(), locationElements);
if (objModel == null) {
throw new PrerequisiteException("Output System does not have model for: " + location);
}
String[] factinfo = prereq.getKey().split("=");
FactKey<?> fk = FactKey.valueOf(factinfo[0]);
Object targetVal = fk.getFormatManager().convertIndirect(factinfo[1]);
int runningTotal = 0;
for (Reducible r : objModel) {
Indirect<?> cdoVal = r.getCDOMObject().get(fk);
if (targetVal.equals(cdoVal)) {
runningTotal++;
}
}
runningTotal = prereq.getOperator().compare(runningTotal, number);
return countedTotal(prereq, runningTotal);
}
Aggregations