Search in sources :

Example 46 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class PCGVer2Parser method processTransitionChoice.

private <T> boolean processTransitionChoice(CDOMObject cdo, Iterator<PCGElement> it2, String name, String dString, PersistentTransitionChoice<T> tc) {
    SelectableSet<? extends T> choices = tc.getChoices();
    if (dString.equals(choices.getLSTformat())) {
        //Match
        while (it2.hasNext()) {
            String choice = EntityEncoder.decode(it2.next().getText());
            Object obj = tc.decodeChoice(Globals.getContext(), choice);
            if (obj == null) {
                warnings.add(cdo.getDisplayName() + "(" + cdo.getClass().getName() + ")\nCould not decode " + choice + " for ADD: " + name + "|" + dString);
            } else {
                tc.restoreChoice(thePC, cdo, tc.castChoice(obj));
            }
        }
        return true;
    } else {
        return false;
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject) PObject(pcgen.core.PObject)

Example 47 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class CharacterFacadeImpl method isQualifiedFor.

@Override
public boolean isQualifiedFor(TempBonusFacade tempBonusFacade) {
    if (!(tempBonusFacade instanceof TempBonusFacadeImpl)) {
        return false;
    }
    TempBonusFacadeImpl tempBonus = (TempBonusFacadeImpl) tempBonusFacade;
    CDOMObject originObj = tempBonus.getOriginObj();
    if (!theCharacter.isQualified(originObj)) {
        return false;
    }
    return true;
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject)

Example 48 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class CharacterFacadeImpl method removeTempBonus.

@Override
public void removeTempBonus(TempBonusFacade bonusFacade) {
    if (bonusFacade == null || !(bonusFacade instanceof TempBonusFacadeImpl)) {
        return;
    }
    TempBonusFacadeImpl tempBonus = (TempBonusFacadeImpl) bonusFacade;
    Equipment aEq = null;
    if (tempBonus.getTarget() instanceof Equipment) {
        aEq = (Equipment) tempBonus.getTarget();
    }
    CDOMObject originObj = tempBonus.getOriginObj();
    TempBonusHelper.removeBonusFromCharacter(theCharacter, aEq, originObj);
    appliedTempBonuses.removeElement(tempBonus);
    refreshStatScores();
    postLevellingUpdates();
}
Also used : Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject)

Example 49 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class CharacterFacadeImpl method addTempBonus.

@Override
public void addTempBonus(TempBonusFacade bonusFacade) {
    if (bonusFacade == null || !(bonusFacade instanceof TempBonusFacadeImpl)) {
        return;
    }
    TempBonusFacadeImpl tempBonus = (TempBonusFacadeImpl) bonusFacade;
    // Allow selection of target for bonus affecting equipment
    CDOMObject originObj = tempBonus.getOriginObj();
    Equipment aEq = null;
    Object target = TempBonusHelper.getTempBonusTarget(originObj, theCharacter, delegate, infoFactory);
    if (target == null) {
        return;
    }
    TempBonusFacadeImpl appliedTempBonus;
    if (target instanceof Equipment) {
        aEq = (Equipment) target;
        appliedTempBonus = TempBonusHelper.applyBonusToCharacterEquipment(aEq, originObj, theCharacter);
    } else {
        appliedTempBonus = TempBonusHelper.applyBonusToCharacter(originObj, theCharacter);
    }
    // Resolve choices and apply the bonus to the character.
    if (appliedTempBonus == null) {
        return;
    }
    appliedTempBonuses.addElement(appliedTempBonus);
    refreshStatScores();
    postLevellingUpdates();
}
Also used : Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject) CDOMObject(pcgen.cdom.base.CDOMObject) QualifiedObject(pcgen.core.QualifiedObject) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject) PObject(pcgen.core.PObject)

Example 50 with CDOMObject

use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.

the class VariableActor method process.

@Override
public TemplateModel process(CharID id, CDOMObject obj) throws TemplateModelException {
    ScopeInstance varScope = scopeFacet.getGlobalScope(id);
    VariableID<?> varID = variableLibraryFacet.getVariableID(id.getDatasetID(), varScope, varName);
    Object value = variableStoreFacet.getValue(id, varID);
    return wrapperFacet.wrap(id, value);
}
Also used : ScopeInstance(pcgen.base.formula.base.ScopeInstance) CDOMObject(pcgen.cdom.base.CDOMObject)

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