combatlevel plugin: fix prayer levels until combat level calculation
Add more prayer level tests to expose a bug in which needed prayer levels for next combat level was 0 instead of 2 in some corner cases and implemented fixes. For example: Let prayer level p be an odd number. The current combat level is exactly same for p and p - 1. Therefore given n is the needed prayer levels for a combat level with p - 1 prayer then n - 1 is the needed prayer levels for a combal level with p prayer. Further more the usage of Math.floor was incorrect in every cases so it is changed to Math.ceil.
This commit is contained in:
@@ -168,12 +168,18 @@ class CombatLevelOverlay extends Overlay
|
||||
@VisibleForTesting
|
||||
static int calcLevelsPray(double start, int end, int prayerLevel)
|
||||
{
|
||||
final int neededLevels = (int) Math.floor(calcMultipliedLevels(start, end, PRAY_MULT));
|
||||
int neededLevels = (int) Math.ceil(calcMultipliedLevels(start, end, PRAY_MULT));
|
||||
|
||||
if (prayerLevel % 2 != 0)
|
||||
{
|
||||
neededLevels--;
|
||||
}
|
||||
|
||||
if ((prayerLevel + neededLevels) % 2 != 0)
|
||||
{
|
||||
return neededLevels + 1;
|
||||
}
|
||||
|
||||
return neededLevels;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user