/* (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); }
/** * Initializes the connections for AgeSetFacet to other facets. * * <p>This method is automatically called by the Spring framework during initialization of the * AgeSetFacet. */ public void init() { raceFacet.addDataFacetChangeListener(this); regionFacet.addDataFacetChangeListener(this); ageFacet.addDataFacetChangeListener(this); bioSetFacet.addDataFacetChangeListener(this); OutputDB.register("ageset", this); }
private void classSetUp() { OutputDB.reset(); df.init(); }