Add guard for not having checked at all.

This commit is contained in:
asofold 2014-03-25 10:48:08 +01:00
parent 90a1255229
commit b6034162ee
3 changed files with 10 additions and 2 deletions

View File

@ -166,7 +166,10 @@ public class Direction extends Check {
public boolean loopFinish(final Player player, final Location loc, final Entity damaged, final DirectionContext context, final boolean forceViolation, final FightData data, final FightConfig cc) { public boolean loopFinish(final Player player, final Location loc, final Entity damaged, final DirectionContext context, final boolean forceViolation, final FightData data, final FightConfig cc) {
boolean cancel = false; boolean cancel = false;
final double off = forceViolation && context.minViolation != Double.MAX_VALUE ? context.minViolation : context.minResult; final double off = forceViolation && context.minViolation != Double.MAX_VALUE ? context.minViolation : context.minResult;
if (off > 0.1) { if (off == Double.MAX_VALUE) {
return false;
}
else if (off > 0.1) {
// Add the overall violation level of the check. // Add the overall violation level of the check.
data.directionVL += context.minViolation; data.directionVL += context.minViolation;
@ -178,7 +181,8 @@ public class Direction extends Check {
// Deal an attack penalty time. // Deal an attack penalty time.
data.attackPenalty.applyPenalty(cc.directionPenalty); data.attackPenalty.applyPenalty(cc.directionPenalty);
} }
} else { }
else {
// Reward the player by lowering their violation level. // Reward the player by lowering their violation level.
data.directionVL *= 0.8D; data.directionVL *= 0.8D;
} }

View File

@ -251,6 +251,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
reachPassed = true; reachPassed = true;
} }
} }
// TODO: For efficiency one could omit checking at all if reach is failed all the time.
if (directionEnabled && (reachPassed || !directionPassed)) { if (directionEnabled && (reachPassed || !directionPassed)) {
if (direction.loopCheck(player, damagedLoc, damagedPlayer, entry, directionContext, data, cc)) { if (direction.loopCheck(player, damagedLoc, damagedPlayer, entry, directionContext, data, cc)) {
thisPassed = false; thisPassed = false;

View File

@ -215,6 +215,9 @@ public class Reach extends Check {
*/ */
public boolean loopFinish(final Player player, final Location pLoc, final Entity damaged, final ReachContext context, final boolean forceViolation, final FightData data, final FightConfig cc) { public boolean loopFinish(final Player player, final Location pLoc, final Entity damaged, final ReachContext context, final boolean forceViolation, final FightData data, final FightConfig cc) {
final double lenpRel = forceViolation && context.minViolation != Double.MAX_VALUE ? context.minViolation : context.minResult; final double lenpRel = forceViolation && context.minViolation != Double.MAX_VALUE ? context.minViolation : context.minResult;
if (lenpRel == Double.MAX_VALUE) {
return false;
}
double violation = lenpRel - context.distanceLimit; double violation = lenpRel - context.distanceLimit;
boolean cancel = false; boolean cancel = false;
if (violation > 0) { if (violation > 0) {