@@ -100,6 +100,7 @@ public class SlayerPlugin extends Plugin
|
||||
//NPC messages
|
||||
private static final Pattern NPC_ASSIGN_MESSAGE = Pattern.compile(".*Your new task is to kill\\s*(\\d*) (.*)\\.");
|
||||
private static final Pattern NPC_ASSIGN_BOSS_MESSAGE = Pattern.compile("^Excellent. You're now assigned to kill (?:the )?(.*) (\\d+) times.*Your reward point tally is (.*)\\.$");
|
||||
private static final Pattern NPC_ASSIGN_FIRST_MESSAGE = Pattern.compile("^We'll start you off hunting (.*), you'll need to kill (\\d*) of them.");
|
||||
private static final Pattern NPC_CURRENT_MESSAGE = Pattern.compile("You're still hunting (.*); you have (\\d*) to go\\..*");
|
||||
|
||||
//Reward UI
|
||||
@@ -270,6 +271,7 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
String npcText = Text.sanitizeMultilineText(npcDialog.getText()); //remove color and linebreaks
|
||||
final Matcher mAssign = NPC_ASSIGN_MESSAGE.matcher(npcText); //number, name
|
||||
final Matcher mAssignFirst = NPC_ASSIGN_FIRST_MESSAGE.matcher(npcText); //name, number
|
||||
final Matcher mAssignBoss = NPC_ASSIGN_BOSS_MESSAGE.matcher(npcText); // name, number, points
|
||||
final Matcher mCurrent = NPC_CURRENT_MESSAGE.matcher(npcText); //name, number
|
||||
|
||||
@@ -277,6 +279,10 @@ public class SlayerPlugin extends Plugin
|
||||
{
|
||||
setTask(mAssign.group(2), Integer.parseInt(mAssign.group(1)));
|
||||
}
|
||||
else if (mAssignFirst.find())
|
||||
{
|
||||
setTask(mAssignFirst.group(1), Integer.parseInt(mAssignFirst.group(2)));
|
||||
}
|
||||
else if (mAssignBoss.find())
|
||||
{
|
||||
setTask(mAssignBoss.group(1), Integer.parseInt(mAssignBoss.group(2)));
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
public class SlayerPluginTest
|
||||
{
|
||||
private static final String TASK_NEW = "Your new task is to kill 231 Suqahs.";
|
||||
private static final String TASK_NEW_FIRST = "We'll start you off hunting goblins, you'll need to kill 17 of them.";
|
||||
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_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.";
|
||||
@@ -146,6 +147,18 @@ public class SlayerPluginTest
|
||||
assertEquals(231, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_FIRST);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("goblins", slayerPlugin.getTaskName());
|
||||
assertEquals(17, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewNpcContactTask()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user