/* (non-Javadoc) * @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", prereq.toString())); // $NON-NLS-1$ } 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); }
protected void finishLoad() { context.commit(); SourceFileLoader.processFactDefinitions(context); context.getReferenceContext().buildDeferredObjects(); context.getReferenceContext().buildDerivedObjects(); context.resolveDeferredTokens(); assertTrue(context.getReferenceContext().resolveReferences(null)); context.resolvePostDeferredTokens(); context.loadCampaignFacets(); pc = new PlayerCharacter(); id = pc.getCharID(); }