use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class TempBonusHelper method removeBonusFromCharacter.
static void removeBonusFromCharacter(PlayerCharacter pc, Equipment aEq, CDOMObject aCreator) {
for (Map.Entry<BonusObj, BonusManager.TempBonusInfo> me : pc.getTempBonusMap().entrySet()) {
BonusObj aBonus = me.getKey();
TempBonusInfo tbi = me.getValue();
Object aC = tbi.source;
if (aCreator != aC) {
continue;
}
Object aT = tbi.target;
if ((aT instanceof Equipment) && (aEq != null)) {
if (aEq.equals(aT)) {
pc.removeTempBonus(aBonus);
pc.removeTempBonusItemList((Equipment) aT);
((Equipment) aT).removeTempBonus(aBonus);
((Equipment) aT).setAppliedName(EMPTY_STRING);
}
} else if ((aT instanceof PlayerCharacter) && (aEq == null)) {
pc.removeTempBonus(aBonus);
}
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class Gui2InfoFactory method getDescription.
@Override
public String getDescription(TempBonusFacade tempBonusFacade) {
if (tempBonusFacade == null || !(tempBonusFacade instanceof TempBonusFacadeImpl)) {
return EMPTY_STRING;
}
try {
TempBonusFacadeImpl tempBonus = (TempBonusFacadeImpl) tempBonusFacade;
CDOMObject originObj = tempBonus.getOriginObj();
String desc = originObj.getSafe(StringKey.TEMP_DESCRIPTION);
if (StringUtils.isEmpty(desc)) {
if (originObj instanceof Spell) {
Spell sp = (Spell) originObj;
desc = DescriptionFormatting.piWrapDesc(sp, pc.getDescription(sp), false);
} else if (originObj instanceof Ability) {
Ability ab = (Ability) originObj;
List<CNAbility> wrappedAbility = Collections.singletonList(CNAbilityFactory.getCNAbility(ab.getCDOMCategory(), Nature.NORMAL, ab));
desc = DescriptionFormatting.piWrapDesc(ab, pc.getDescription(wrappedAbility), false);
}
}
return desc;
} catch (Exception e) {
//$NON-NLS-1$
Logging.errorPrint("Failed to get description for " + tempBonusFacade, e);
return EMPTY_STRING;
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class StatIntegrationTest method testUnlockInnocent.
@Test
public void testUnlockInnocent() {
CDOMObject r1 = new Race();
causeUnlock(r1, stat2);
testNonAbilityUnset();
testLockUnset();
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class GlobalCompanionListTest method containsExpected.
@Override
protected boolean containsExpected() {
/*
* TODO This indicates that FollowerOptionFacet is not really pure
* content - it is doing filtering as well
*/
Map<FollowerOption, CDOMObject> available = foFacet.getAvailableFollowers(id, "Animal Companion", null);
if (available.size() != 1) {
return false;
}
FollowerOption entry = available.keySet().iterator().next();
boolean raceMatches = entry.getRaceRef().equals(context.getReferenceContext().getCDOMReference(Race.class, "Ape"));
boolean listMatches = entry.getListRef().equals(context.getReferenceContext().getCDOMReference(CompanionList.class, "Animal Companion"));
boolean adjMatches = entry.getAdjustment() == -3;
return raceMatches && listMatches && adjMatches;
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class BonusManager method calcBonusesWithCost.
public double calcBonusesWithCost(List<BonusObj> list) {
double totalBonus = 0;
for (BonusObj aBonus : list) {
final CDOMObject anObj = (CDOMObject) getSourceObject(aBonus);
if (anObj == null) {
continue;
}
double iBonus = 0;
if (aBonus.qualifies(pc, anObj)) {
iBonus = aBonus.resolve(pc, anObj.getQualifiedKey()).doubleValue();
}
int k;
if (ChooseActivation.hasNewChooseToken(anObj)) {
k = 0;
for (String aString : pc.getConsolidatedAssociationList(anObj)) {
if (aString.equalsIgnoreCase(aBonus.getBonusInfo())) {
++k;
}
}
} else {
k = 1;
}
if ((k == 0) && !CoreUtility.doublesEqual(iBonus, 0)) {
totalBonus += iBonus;
} else {
totalBonus += (iBonus * k);
}
}
return totalBonus;
}
Aggregations