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:
SomeoneWithAnInternetConnection
2017-12-15 11:44:07 -05:00
parent e46d9e8c17
commit aad76b9bab
2 changed files with 24 additions and 9 deletions

View File

@@ -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