slayer plugin: Add parsing for boss task assignments

Ref: https://user-images.githubusercontent.com/2199511/45984305-f9c22600-c04f-11e8-8cda-a8f4ab40e678.png
This commit is contained in:
Jordan Atwood
2018-09-24 16:05:55 -07:00
parent 3e631f84d4
commit 20922aea9a
2 changed files with 31 additions and 11 deletions

View File

@@ -95,6 +95,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 (.*) (\\d+) times.*Your reward point tally is (.*)\\.$");
private static final Pattern NPC_CURRENT_MESSAGE = Pattern.compile("You're still hunting (.*); you have (\\d*) to go\\..*");
//Reward UI
@@ -262,19 +263,23 @@ public class SlayerPlugin extends Plugin
if (NPCDialog != null)
{
String NPCText = Text.removeTags(NPCDialog.getText()); //remove color and linebreaks
Matcher mAssign = NPC_ASSIGN_MESSAGE.matcher(NPCText); //number, name
Matcher mCurrent = NPC_CURRENT_MESSAGE.matcher(NPCText); //name, number
boolean found1 = mAssign.find();
boolean found2 = mCurrent.find();
if (!found1 && !found2)
final Matcher mAssign = NPC_ASSIGN_MESSAGE.matcher(NPCText); //number, name
final Matcher mAssignBoss = NPC_ASSIGN_BOSS_MESSAGE.matcher(NPCText); // name, number, points
final Matcher mCurrent = NPC_CURRENT_MESSAGE.matcher(NPCText); //name, number
if (mAssign.find())
{
return;
setTask(mAssign.group(2), Integer.parseInt(mAssign.group(1)));
}
else if (mAssignBoss.find())
{
setTask(mAssignBoss.group(1), Integer.parseInt(mAssignBoss.group(2)));
points = Integer.parseInt(mAssignBoss.group(3).replaceAll(",", ""));
}
else if (mCurrent.find())
{
setTask(mCurrent.group(1), Integer.parseInt(mCurrent.group(2)));
}
String taskName = found1 ? mAssign.group(2) : mCurrent.group(1);
int amount = Integer.parseInt(found1 ? mAssign.group(1) : mCurrent.group(2));
setTask(taskName, amount);
}
Widget braceletBreakWidget = client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT);