Merge pull request #2271 from LeviSchuck/xp-negative
Fix negative total XP calculation when skill starts
This commit is contained in:
@@ -71,7 +71,11 @@ class XpStateSingle
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long timeElapsedInSeconds = Duration.between(skillTimeStart, Instant.now()).getSeconds();
|
// If the skill started just now, we can divide by near zero, this results in odd behavior.
|
||||||
|
// To prevent that, pretend the skill has been active for a minute (60 seconds)
|
||||||
|
// This will create a lower estimate for the first minute,
|
||||||
|
// but it isn't ridiculous like saying 2 billion XP per hour.
|
||||||
|
long timeElapsedInSeconds = Math.max(60, Duration.between(skillTimeStart, Instant.now()).getSeconds());
|
||||||
return (int) ((1.0 / (timeElapsedInSeconds / 3600.0)) * value);
|
return (int) ((1.0 / (timeElapsedInSeconds / 3600.0)) * value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user