Skip to content

Commit

Permalink
Add guard for not having checked at all.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Mar 25, 2014
1 parent 90a1255 commit b603416
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Expand Up @@ -166,7 +166,10 @@ public boolean loopCheck(final Player player, final Location loc, final Entity d
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;
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.
data.directionVL += context.minViolation;

Expand All @@ -178,7 +181,8 @@ public boolean loopFinish(final Player player, final Location loc, final Entity
// Deal an attack penalty time.
data.attackPenalty.applyPenalty(cc.directionPenalty);
}
} else {
}
else {
// Reward the player by lowering their violation level.
data.directionVL *= 0.8D;
}
Expand Down
Expand Up @@ -251,6 +251,7 @@ else if (normalizedMove > 2.0 && Improbable.check(player, 1f, now, "fight.speed"
reachPassed = true;
}
}
// TODO: For efficiency one could omit checking at all if reach is failed all the time.
if (directionEnabled && (reachPassed || !directionPassed)) {
if (direction.loopCheck(player, damagedLoc, damagedPlayer, entry, directionContext, data, cc)) {
thisPassed = false;
Expand Down
Expand Up @@ -215,6 +215,9 @@ else if (context.pY >= dY + context.damagedHeight) {
*/
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;
if (lenpRel == Double.MAX_VALUE) {
return false;
}
double violation = lenpRel - context.distanceLimit;
boolean cancel = false;
if (violation > 0) {
Expand Down

0 comments on commit b603416

Please sign in to comment.