Add support for parsing Wilderness assignment updates to slayer plugin (#5757)
Fixes #5687
This commit is contained in:
committed by
Tomas Slusny
parent
13a85f39ea
commit
2adb760f02
@@ -78,7 +78,7 @@ import net.runelite.client.util.Text;
|
|||||||
public class SlayerPlugin extends Plugin
|
public class SlayerPlugin extends Plugin
|
||||||
{
|
{
|
||||||
//Chat messages
|
//Chat messages
|
||||||
private static final Pattern CHAT_GEM_PROGRESS_MESSAGE = Pattern.compile("You're assigned to kill (.*); only (\\d*) more to go\\.");
|
private static final Pattern CHAT_GEM_PROGRESS_MESSAGE = Pattern.compile("You're assigned to kill (.*?)(?: in the Wilderness)?; only (\\d*) more to go\\.");
|
||||||
private static final String CHAT_GEM_COMPLETE_MESSAGE = "You need something new to hunt.";
|
private static final String CHAT_GEM_COMPLETE_MESSAGE = "You need something new to hunt.";
|
||||||
private static final Pattern CHAT_COMPLETE_MESSAGE = Pattern.compile("(?:\\d+,)*\\d+");
|
private static final Pattern CHAT_COMPLETE_MESSAGE = Pattern.compile("(?:\\d+,)*\\d+");
|
||||||
private static final String CHAT_CANCEL_MESSAGE = "Your task has been cancelled.";
|
private static final String CHAT_CANCEL_MESSAGE = "Your task has been cancelled.";
|
||||||
@@ -418,13 +418,13 @@ public class SlayerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg);
|
Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg);
|
||||||
|
|
||||||
if (!mProgress.find())
|
if (!mProgress.find())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String taskName = mProgress.group(1);
|
String taskName = mProgress.group(1);
|
||||||
int amount = Integer.parseInt(mProgress.group(2));
|
int amount = Integer.parseInt(mProgress.group(2));
|
||||||
|
|
||||||
setTask(taskName, amount);
|
setTask(taskName, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ public class SlayerPluginTest
|
|||||||
{
|
{
|
||||||
private static final String TASK_NEW = "Your new task is to kill 231 Suqahs.";
|
private static final String TASK_NEW = "Your new task is to kill 231 Suqahs.";
|
||||||
private static final String TASK_NEW_NPC_CONTACT = "Excellent, you're doing great. Your new task is to kill<br>211 Suqahs.";
|
private static final String TASK_NEW_NPC_CONTACT = "Excellent, you're doing great. Your new task is to kill<br>211 Suqahs.";
|
||||||
|
private static final String TASK_CHECKSLAYERGEM_WILDERNESS = "You're assigned to kill Suqahs in the Wilderness; only 211 more to go.";
|
||||||
|
private static final String TASK_CHECKSLAYERGEM = "You're assigned to kill Suqahs; only 211 more to go.";
|
||||||
|
|
||||||
private static final String TASK_BOSS_NEW = "Excellent. You're now assigned to kill Vet'ion 3 times.<br>Your reward point tally is 914.";
|
private static final String TASK_BOSS_NEW = "Excellent. You're now assigned to kill Vet'ion 3 times.<br>Your reward point tally is 914.";
|
||||||
|
|
||||||
@@ -164,6 +166,24 @@ public class SlayerPluginTest
|
|||||||
assertEquals(914, slayerPlugin.getPoints());
|
assertEquals(914, slayerPlugin.getPoints());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCheckSlayerGem()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "", TASK_CHECKSLAYERGEM, null);
|
||||||
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||||
|
assertEquals(211, slayerPlugin.getAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCheckSlayerGemWildernessTask()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "", TASK_CHECKSLAYERGEM_WILDERNESS, null);
|
||||||
|
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||||
|
assertEquals(211, slayerPlugin.getAmount());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExistingTask()
|
public void testExistingTask()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user