slayer: Add combat bracelet task update handling
Fixes runelite/runelite#4473
This commit is contained in:
@@ -92,6 +92,7 @@ public class SlayerPlugin extends Plugin
|
||||
private static final Pattern CHAT_BRACELET_SLAUGHTER_CHARGE_REGEX = Pattern.compile("Your bracelet of slaughter has (\\d{1,2}) charge[s]? left.");
|
||||
private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE = "Your expeditious bracelet has ";
|
||||
private static final Pattern CHAT_BRACELET_EXPEDITIOUS_CHARGE_REGEX = Pattern.compile("Your expeditious bracelet has (\\d{1,2}) charge[s]? left.");
|
||||
private static final Pattern COMBAT_BRACELET_TASK_UPDATE_MESSAGE = Pattern.compile("^You still need to kill (\\d+) monsters to complete your current Slayer assignment");
|
||||
|
||||
//NPC messages
|
||||
private static final Pattern NPC_ASSIGN_MESSAGE = Pattern.compile(".*Your new task is to kill\\s*(\\d*) (.*)\\.");
|
||||
@@ -419,13 +420,22 @@ public class SlayerPlugin extends Plugin
|
||||
|
||||
Matcher mProgress = CHAT_GEM_PROGRESS_MESSAGE.matcher(chatMsg);
|
||||
|
||||
if (!mProgress.find())
|
||||
if (mProgress.find())
|
||||
{
|
||||
String gemTaskName = mProgress.group(1);
|
||||
int gemAmount = Integer.parseInt(mProgress.group(2));
|
||||
setTask(gemTaskName, gemAmount);
|
||||
return;
|
||||
}
|
||||
|
||||
final Matcher bracerProgress = COMBAT_BRACELET_TASK_UPDATE_MESSAGE.matcher(chatMsg);
|
||||
|
||||
if (bracerProgress.find())
|
||||
{
|
||||
final int taskAmount = Integer.parseInt(bracerProgress.group(1));
|
||||
setTask(taskName, taskAmount);
|
||||
return;
|
||||
}
|
||||
String taskName = mProgress.group(1);
|
||||
int amount = Integer.parseInt(mProgress.group(2));
|
||||
setTask(taskName, amount);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -58,6 +58,7 @@ public class SlayerPluginTest
|
||||
private static final String TASK_NEW_FROM_PARTNER = "You have received a new Slayer assignment from breaklulz: Dust Devils (377)";
|
||||
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_UPDATE_COMBAT_BRACELET = "You still need to kill 30 monsters to complete your current Slayer assignment";
|
||||
|
||||
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_THE = "Excellent. You're now assigned to kill the Chaos <br>Elemental 3 times. Your reward point tally is 914.";
|
||||
@@ -417,4 +418,17 @@ public class SlayerPluginTest
|
||||
assertEquals(41, slayerPlugin.getAmount());
|
||||
assertEquals(1, slayerPlugin.getExpeditiousChargeCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCombatBraceletUpdate()
|
||||
{
|
||||
slayerPlugin.setTaskName("Suqahs");
|
||||
slayerPlugin.setAmount(231);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(SERVER, "", TASK_UPDATE_COMBAT_BRACELET, null);
|
||||
slayerPlugin.onChatMessage(chatMessage);
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getTaskName());
|
||||
assertEquals(30, slayerPlugin.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user