(final Prerequisite prereq, final PlayerCharacter aPC, CDOMObject source)
| 37 | { |
| 38 | |
| 39 | @Override |
| 40 | public int passes(final Prerequisite prereq, final PlayerCharacter aPC, CDOMObject source) |
| 41 | throws PrerequisiteException |
| 42 | { |
| 43 | final int number; |
| 44 | try |
| 45 | { |
| 46 | number = Integer.parseInt(prereq.getOperand()); |
| 47 | } |
| 48 | catch (NumberFormatException exceptn) |
| 49 | { |
| 50 | throw new PrerequisiteException( |
| 51 | LanguageBundle.getFormattedString("PreFact.error", prereq.toString()), exceptn); //$NON-NLS-1$ |
| 52 | } |
| 53 | |
| 54 | String location = prereq.getCategoryName(); |
| 55 | String[] locationElements = location.split("\\."); |
| 56 | Iterable<Reducible> objModel = (Iterable<Reducible>) OutputDB.getIterable(aPC.getCharID(), locationElements); |
| 57 | if (objModel == null) |
| 58 | { |
| 59 | throw new PrerequisiteException("Output System does not have model for: " + location); |
| 60 | } |
| 61 | |
| 62 | String[] factinfo = prereq.getKey().split("="); |
| 63 | FactKey<?> fk = FactKey.valueOf(factinfo[0]); |
| 64 | Object targetVal = fk.getFormatManager().convertIndirect(factinfo[1]); |
| 65 | |
| 66 | int runningTotal = 0; |
| 67 | for (Reducible r : objModel) |
| 68 | { |
| 69 | Indirect<?> cdoVal = r.getCDOMObject().get(fk); |
| 70 | if (targetVal.equals(cdoVal)) |
| 71 | { |
| 72 | runningTotal++; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | runningTotal = prereq.getOperator().compare(runningTotal, number); |
| 77 | return countedTotal(prereq, runningTotal); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Get the type of prerequisite handled by this token. |
nothing calls this directly
no test coverage detected