/* (non-Javadoc) * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter) */ @Override public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source) { // // If game mode doesn't support alignment, then pass the prereq // int runningTotal = 0; if (Globals.getGameModeAlignmentText().length() == 0) { runningTotal = 1; } else { CDOMSingleRef<PCAlignment> deityAlign = null; // $NON-NLS-1$ Deity deity = display.getDeity(); if (deity != null) { deityAlign = deity.get(ObjectKey.ALIGNMENT); } if (deityAlign != null) { String desiredAlignIdentifier = prereq.getOperand(); PCAlignment desiredAlign = getPCAlignment(desiredAlignIdentifier); if (desiredAlign.equals(deityAlign.get())) { runningTotal = 1; } } } return countedTotal(prereq, runningTotal); }
public void testBasicObjectKeyActor() { Deity d = new Deity(); d.setName("Bob"); BigDecimal expectedResult = new BigDecimal("4.063"); df.set(id, d); d.put(ObjectKey.COST, expectedResult); ObjectKeyActor<BigDecimal> oka = new ObjectKeyActor<BigDecimal>(ObjectKey.COST); CDOMObjectWrapper.getInstance().load(d.getClass(), "cost", oka); processThroughFreeMarker("${deity.cost}", expectedResult.toString()); }
public void testWrappedObjectKeyActor() { Deity d = new Deity(); d.setName("Bob"); PCStat str = new PCStat(); str.setName("Strength"); BigDecimal expectedResult = new BigDecimal("4.063"); str.put(ObjectKey.COST, expectedResult); df.set(id, d); d.put(ObjectKey.SPELL_STAT, CDOMDirectSingleRef.getRef(str)); ObjectKeyActor<BigDecimal> oka_cost = new ObjectKeyActor<BigDecimal>(ObjectKey.COST); CDOMObjectWrapper.getInstance().load(str.getClass(), "cost", oka_cost); ObjectKeyActor<CDOMSingleRef<PCStat>> oka_stat = new ObjectKeyActor<CDOMSingleRef<PCStat>>(ObjectKey.SPELL_STAT); CDOMObjectWrapper.getInstance().load(d.getClass(), "stat", oka_stat); processThroughFreeMarker("${deity.stat}", str.getDisplayName()); processThroughFreeMarker("${deity.stat.cost}", expectedResult.toString()); }
@Override protected void setUp() throws Exception { super.setUp(); Domain goodDomain = new Domain(); goodDomain.setName("Good"); Globals.getContext().ref.importObject(goodDomain); Domain animalDomain = new Domain(); animalDomain.setName("Animal"); Globals.getContext().ref.importObject(animalDomain); deity = new Deity(); deity.setName("Test Deity"); deity.put(ObjectKey.ALIGNMENT, ng); deity.putToList( Deity.DOMAINLIST, CDOMDirectSingleRef.getRef(goodDomain), new SimpleAssociatedObject()); deity.putToList( Deity.DOMAINLIST, CDOMDirectSingleRef.getRef(animalDomain), new SimpleAssociatedObject()); }