Fix IllegalArgumentExceptions from XPGlobes' tooltips for level 1 stats
To draw the progress bar, XPGlobesOverlay.drawTooltipIfMouseover() uses Experience.getXPForLevel(), which threw an IllegalArgumentException when asked about level 1. This change shifts the XP_FOR_LEVEL array over by one, so that XP_FOR_LEVEL[0] is the XP required to reach level 1 (i.e. 0), rather than the XP required for level 2.
This commit is contained in:
@@ -36,6 +36,21 @@ public class ExperienceTest
|
||||
{
|
||||
int xp = Experience.getXpForLevel(99);
|
||||
Assert.assertEquals(XP_FOR_99, xp);
|
||||
|
||||
xp = Experience.getXpForLevel(1);
|
||||
Assert.assertEquals(0, xp);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testGetXpForHighLevel()
|
||||
{
|
||||
int xp = Experience.getXpForLevel(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testGetXpForLowLevel()
|
||||
{
|
||||
int xp = Experience.getXpForLevel(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user