slayer plugin: fix unknown tasks not decrementing counter
This commit is contained in:
@@ -537,12 +537,9 @@ public class SlayerPlugin extends Plugin
|
|||||||
|
|
||||||
final Task task = Task.getTask(taskName);
|
final Task task = Task.getTask(taskName);
|
||||||
|
|
||||||
if (task == null)
|
// null tasks are technically valid, it only means they arent explicitly defined in the Task enum
|
||||||
{
|
// allow them through so that if there is a task capture failure the counter will still work
|
||||||
return;
|
final int taskKillExp = task != null ? task.getExpectedKillExp() : 0;
|
||||||
}
|
|
||||||
|
|
||||||
final int taskKillExp = task.getExpectedKillExp();
|
|
||||||
|
|
||||||
// Only count exp gain as a kill if the task either has no expected exp for a kill, or if the exp gain is equal
|
// Only count exp gain as a kill if the task either has no expected exp for a kill, or if the exp gain is equal
|
||||||
// to the expected exp gain for the task.
|
// to the expected exp gain for the task.
|
||||||
|
|||||||
@@ -420,6 +420,52 @@ public class SlayerPluginTest
|
|||||||
verifyNoMoreInteractions(notifier);
|
verifyNoMoreInteractions(notifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCorrectlyCapturedTaskKill()
|
||||||
|
{
|
||||||
|
final Player player = mock(Player.class);
|
||||||
|
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||||
|
when(client.getLocalPlayer()).thenReturn(player);
|
||||||
|
|
||||||
|
final ExperienceChanged experienceChanged = new ExperienceChanged();
|
||||||
|
experienceChanged.setSkill(Skill.SLAYER);
|
||||||
|
|
||||||
|
when(client.getSkillExperience(Skill.SLAYER)).thenReturn(100);
|
||||||
|
slayerPlugin.onExperienceChanged(experienceChanged);
|
||||||
|
|
||||||
|
slayerPlugin.setTaskName("Dagannoth");
|
||||||
|
slayerPlugin.setAmount(143);
|
||||||
|
|
||||||
|
when(client.getSkillExperience(Skill.SLAYER)).thenReturn(110);
|
||||||
|
slayerPlugin.onExperienceChanged(experienceChanged);
|
||||||
|
|
||||||
|
assertEquals(142, slayerPlugin.getAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIncorrectlyCapturedTaskKill()
|
||||||
|
{
|
||||||
|
final Player player = mock(Player.class);
|
||||||
|
when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
|
||||||
|
when(client.getLocalPlayer()).thenReturn(player);
|
||||||
|
|
||||||
|
final ExperienceChanged experienceChanged = new ExperienceChanged();
|
||||||
|
experienceChanged.setSkill(Skill.SLAYER);
|
||||||
|
|
||||||
|
when(client.getSkillExperience(Skill.SLAYER)).thenReturn(100);
|
||||||
|
slayerPlugin.onExperienceChanged(experienceChanged);
|
||||||
|
|
||||||
|
slayerPlugin.setTaskName("Monster");
|
||||||
|
slayerPlugin.setAmount(98);
|
||||||
|
|
||||||
|
assert Task.getTask("Monster") == null;
|
||||||
|
|
||||||
|
when(client.getSkillExperience(Skill.SLAYER)).thenReturn(110);
|
||||||
|
slayerPlugin.onExperienceChanged(experienceChanged);
|
||||||
|
|
||||||
|
assertEquals(97, slayerPlugin.getAmount());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJadTaskKill()
|
public void testJadTaskKill()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user