runelite-api: fix combat fornula

This commit is contained in:
Adam
2018-01-14 10:42:55 -05:00
parent c68bde3cec
commit 6801ac1843
2 changed files with 9 additions and 8 deletions

View File

@@ -24,6 +24,9 @@
*/
package net.runelite.api;
import static java.lang.Math.floor;
import static java.lang.Math.max;
public class Experience
{
/**
@@ -93,16 +96,13 @@ public class Experience
int defenceLevel, int hitpointsLevel, int magicLevel,
int rangeLevel, int prayerLevel)
{
double melee = 0.25 * (defenceLevel + hitpointsLevel + Math.floor(prayerLevel / 2))
+ 0.325 * (attackLevel + strengthLevel);
double base = 0.25 * (defenceLevel + hitpointsLevel + floor(prayerLevel / 2));
double range = 0.25 * (defenceLevel + hitpointsLevel + Math.floor(prayerLevel / 2))
+ 0.325 * (Math.floor(rangeLevel / 2));
double melee = 0.325 * (attackLevel + strengthLevel);
double range = 0.325 * (floor(rangeLevel / 2) + rangeLevel);
double magic = 0.325 * (floor(magicLevel / 2) + magicLevel);
double magic = 0.25 * (defenceLevel + hitpointsLevel + Math.floor(prayerLevel / 2))
+ 0.325 * (Math.floor(magicLevel / 2));
return Math.max(melee, Math.max(range, magic));
return base + max(melee, max(range, magic));
}
public static int getCombatLevel(int attackLevel, int strengthLevel,

View File

@@ -78,5 +78,6 @@ public class ExperienceTest
public void testGetCombatLevel()
{
Assert.assertEquals(126, Experience.getCombatLevel(99, 99, 99, 99, 70, 42, 98));
Assert.assertEquals(40, Experience.getCombatLevel(27, 22, 1, 36, 64, 45, 1));
}
}