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