diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index 89ad7d1473..c8c02a8bf3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -111,7 +111,7 @@ public class SlayerPlugin extends Plugin private static final Pattern NPC_ASSIGN_MESSAGE = Pattern.compile(".*(?:Your new task is to kill|You are to bring balance to)\\s*(?\\d+) (?.+?)(?: (?:in|on|south of) (?:the )?(?.+))?\\."); private static final Pattern NPC_ASSIGN_BOSS_MESSAGE = Pattern.compile("^(?:Excellent\\. )?You're now assigned to (?:kill|bring balance to) (?:the )?(.*) (\\d+) times.*Your reward point tally is (.*)\\.$"); private static final Pattern NPC_ASSIGN_FIRST_MESSAGE = Pattern.compile("^We'll start you off (?:hunting|bringing balance to) (.*), you'll need to kill (\\d*) of them\\.$"); - private static final Pattern NPC_CURRENT_MESSAGE = Pattern.compile("^You're still (?:hunting|bringing balance to) (?.+)(?: (?:in|on|south of) (?:the )?(?.+), with|; you have) (?\\d+) to go\\..*"); + private static final Pattern NPC_CURRENT_MESSAGE = Pattern.compile("^You're (?:still(?: meant to be)?|currently assigned to) (?:hunting|bringing balance to|kill|bring balance to|slaying) (?.+?)(?: (?:in|on|south of) (?:the )?(?.+))?(?:, with|; (?:you have|only)) (?\\d+)(?: more)? to go\\..*"); //Reward UI private static final Pattern REWARD_POINTS = Pattern.compile("Reward points: ((?:\\d+,)*\\d+)"); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java index f5dc666aca..1c0bbb67f9 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java @@ -86,6 +86,12 @@ public class SlayerPluginTest private static final String TASK_KONAR_BOSS = "You're now assigned to bring balance to the Alchemical
Hydra 35 times. Your reward point tally is 724."; private static final String TASK_EXISTING = "You're still hunting suqahs; you have 222 to go. Come
back when you've finished your task."; + private static final String TASK_EXISTING_KONAR = "You're still bringing balance to adamant dragons in the Lithkren Vault, with 3 to go. Come back when you're finished."; + private static final String TASK_EXISTING_WILDERNESS = "You're still meant to be slaying bandits in the Wilderness; you have 99 to go. Come back when you've finished your task."; + + private static final String TASK_ACTIVATESLAYERGEM = "You're currently assigned to kill fossil island wyverns; only 23 more to go. Your reward point tally is 46."; + private static final String TASK_ACTIVATESLAYERGEM_KONAR = "You're currently assigned to bring balance to adamant dragons in the Lithkren Vault; you have 3 more to go. Your reward point tally is 16."; + private static final String TASK_ACTIVATESLAYERGEM_WILDERNESS = "You're currently assigned to kill bandits in the Wilderness; only 99 more to go. Your reward point tally is 34."; private static final String REWARD_POINTS = "Reward points: 17,566"; @@ -348,6 +354,70 @@ public class SlayerPluginTest assertEquals(222, slayerPlugin.getAmount()); } + @Test + public void testExistingTaskKonar() + { + Widget npcDialog = mock(Widget.class); + when(npcDialog.getText()).thenReturn(TASK_EXISTING_KONAR); + when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); + slayerPlugin.onGameTick(new GameTick()); + + assertEquals("adamant dragons", slayerPlugin.getTaskName()); + assertEquals(3, slayerPlugin.getAmount()); + assertEquals("Lithkren Vault", slayerPlugin.getTaskLocation()); + } + + @Test + public void testExistingTaskWilderness() + { + Widget npcDialog = mock(Widget.class); + when(npcDialog.getText()).thenReturn(TASK_EXISTING_WILDERNESS); + when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); + slayerPlugin.onGameTick(new GameTick()); + + assertEquals("bandits", slayerPlugin.getTaskName()); + assertEquals(99, slayerPlugin.getAmount()); + assertEquals("Wilderness", slayerPlugin.getTaskLocation()); + } + + @Test + public void testSlayergemActivate() + { + Widget npcDialog = mock(Widget.class); + when(npcDialog.getText()).thenReturn(TASK_ACTIVATESLAYERGEM); + when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); + slayerPlugin.onGameTick(new GameTick()); + + assertEquals("fossil island wyverns", slayerPlugin.getTaskName()); + assertEquals(23, slayerPlugin.getAmount()); + } + + @Test + public void testSlayergemActivateKonar() + { + Widget npcDialog = mock(Widget.class); + when(npcDialog.getText()).thenReturn(TASK_ACTIVATESLAYERGEM_KONAR); + when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); + slayerPlugin.onGameTick(new GameTick()); + + assertEquals("adamant dragons", slayerPlugin.getTaskName()); + assertEquals(3, slayerPlugin.getAmount()); + assertEquals("Lithkren Vault", slayerPlugin.getTaskLocation()); + } + + @Test + public void testSlayergemActivateWilderness() + { + Widget npcDialog = mock(Widget.class); + when(npcDialog.getText()).thenReturn(TASK_ACTIVATESLAYERGEM_WILDERNESS); + when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); + slayerPlugin.onGameTick(new GameTick()); + + assertEquals("bandits", slayerPlugin.getTaskName()); + assertEquals(99, slayerPlugin.getAmount()); + assertEquals("Wilderness", slayerPlugin.getTaskLocation()); + } + @Test public void testRewardPointsWidget() {