@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 boolean fightShouldContinue(final BasicFight<? extends BasicCharacterInfo> fight) { boolean enoughTeamsLeft = false; boolean playerPresent = false; final TByteHashSet remainingTeams = new TByteHashSet(); final Collection<? extends BasicCharacterInfo> inPlayFighters = fight.getInPlayOrSimulatingFighters(); for (final BasicCharacterInfo f : inPlayFighters) { if (f.getTeamId() == -1) { EnoughTeamWithPlayersOrCompanionLeftChecker.m_logger.error( (Object) fight.withFightId( "[FIGHT_REFACTOR] On a un fighter inPlay avec un teamId \u00e0 -1 " + f + " - " + ExceptionFormatter.currentStackTrace(8))); } else { remainingTeams.add(f.getTeamId()); enoughTeamsLeft |= (remainingTeams.size() >= fight.getMinTeam()); playerPresent |= (f.getType() == 0 || f.getType() == 5); if (playerPresent && enoughTeamsLeft) { break; } continue; } } return enoughTeamsLeft && playerPresent; }
@Override public int getValidity( final Object criterionUser, final Object criterionTarget, final Object criterionContent, final Object criterionContext) { final BasicCharacterInfo character = CriteriaUtils.getTargetCharacterInfoFromParameters( this.m_target, criterionUser, criterionTarget, criterionContext, criterionContent); if (character == null) { return -1; } final BasicFight<?> fight = (BasicFight<?>) character.getCurrentFight(); if (fight == null) { return -1; } final Collection<? extends BasicCharacterInfo> fighters = (Collection<? extends BasicCharacterInfo>) fight.getFighters(); for (final BasicCharacterInfo fighter : fighters) { if (fighter.getProtector() != null) { return 0; } } return -1; }
@Override public int getValidity( final Object criterionUser, final Object criterionTarget, final Object criterionContent, final Object criterionContext) { final BasicCharacterInfo target = CriteriaUtils.getTargetCharacterInfoFromParameters( this.m_useTarget, criterionUser, criterionTarget, criterionContext, criterionContent); final int effectActionId = (int) this.m_effectActionId.getLongValue( criterionUser, criterionTarget, criterionContent, criterionContext); return target.hasEffectWithActionId(effectActionId) ? 0 : -1; }