Search in sources :

Example 86 with CDOMObject

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();
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) PCClass(pcgen.core.PCClass)

Example 87 with CDOMObject

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();
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) PCClass(pcgen.core.PCClass)

Example 88 with CDOMObject

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();
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject)

Example 89 with CDOMObject

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();
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) PCClass(pcgen.core.PCClass)

Example 90 with CDOMObject

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);
}
Also used : PrerequisiteException(pcgen.core.prereq.PrerequisiteException) CDOMObject(pcgen.cdom.base.CDOMObject) Reducible(pcgen.cdom.base.Reducible)

Aggregations

CDOMObject (pcgen.cdom.base.CDOMObject)235 Test (org.junit.Test)68 CharID (pcgen.cdom.enumeration.CharID)53 PCTemplate (pcgen.core.PCTemplate)30 ArrayList (java.util.ArrayList)22 PCClass (pcgen.core.PCClass)18 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)17 Race (pcgen.core.Race)17 Equipment (pcgen.core.Equipment)15 PlayerCharacter (pcgen.core.PlayerCharacter)15 Map (java.util.Map)14 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)14 CDOMReference (pcgen.cdom.base.CDOMReference)14 BonusObj (pcgen.core.bonus.BonusObj)14 IdentityHashMap (java.util.IdentityHashMap)12 Set (java.util.Set)12 VariableKey (pcgen.cdom.enumeration.VariableKey)11 HashMap (java.util.HashMap)10 CNAbility (pcgen.cdom.content.CNAbility)10 Spell (pcgen.core.spell.Spell)9