@Override public long getLongValue( @Nullable final Object criterionUser, @Nullable final Object criterionTarget, @Nullable final Object criterionContent, @Nullable final Object criterionContext) { if (criterionContext == null) { throw new CriteriaExecutionException("Pas de contexte..."); } final AbstractFight<?> fight = CriteriaUtils.getFight(criterionUser, criterionContext); if (fight == null) { throw new CriteriaExecutionException("Impossible de r\u00e9cup\u00e9rer le combat"); } final byte type = (byte) (this.m_monsters ? 1 : 0); final Collection<? extends BasicCharacterInfo> fighters = fight.getFighters( ProtagonistFilter.inPlay(), ProtagonistFilter.ofType(type), ProtagonistFilter.not( ProtagonistFilter.hasProperty(WorldPropertyType.NOT_PRESENT_IN_TIMELINE))); short level = 0; for (final BasicCharacterInfo f : fighters) { level += f.getLevel(); } return level; }
@Override public int getValidity( final Object criterionUser, final Object criterionTarget, final Object criterionContent, final Object criterionContext) { final CriterionUser targetCharacter = CriteriaUtils.getTargetCriterionUserFromParameters( this.m_target, criterionUser, criterionTarget, criterionContext, criterionContent); final byte worldPropertyId = (byte) this.getWorldPropertyId(); final WorldPropertyType property = WorldPropertyType.getPropertyFromId(worldPropertyId); if (property == null) { throw new CriteriaExecutionException( "Le param\u00e8tre du crit\u00e8re HasWorldProperty doit \u00eatre un id de WorldPropertyType valide (id=" + worldPropertyId + " n'existe pas)"); } final boolean hasProperty = targetCharacter.hasProperty(property); if (!hasProperty) { return -1; } if (this.m_durationToCheck == null) { return 0; } final long duration = this.getDurationToCheck() * 1000L; if (System.currentTimeMillis() - AbstractMonsterTimedPropertyManager.getStateStartTime( targetCharacter.getId(), property) < duration) { return -1; } return 0; }