slayer: fix task tracking & bracelet tracking (#1691)
* fix task tracking * fix slayer bracelet tracking
This commit is contained in:
@@ -76,16 +76,18 @@ public class ItemChargePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
private static final Pattern DODGY_CHECK_PATTERN = Pattern.compile(
|
private static final Pattern DODGY_CHECK_PATTERN = Pattern.compile(
|
||||||
"Your dodgy necklace has (\\d+) charges? left\\.");
|
"Your dodgy necklace has (\\d+) charges? left\\.");
|
||||||
private static final Pattern SLAUGHTER_CHECK_PATTERN = Pattern.compile(
|
private static final String CHAT_BRACELET_SLAUGHTER = "Your bracelet of slaughter prevents your slayer";
|
||||||
|
private static final Pattern CHAT_BRACELET_SLAUGHTER_REGEX = Pattern.compile(
|
||||||
|
"Your bracelet of slaughter prevents your slayer count decreasing. It has (\\d{1,2}) charge[s]? left.");
|
||||||
|
private static final String CHAT_BRACELET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your";
|
||||||
|
private static final Pattern CHAT_BRACELET_EXPEDITIOUS_REGEX = Pattern.compile(
|
||||||
|
"Your expeditious bracelet helps you progress your slayer (?:task )?faster. It has (\\d{1,2}) charge[s]? left.");
|
||||||
|
private static final Pattern CHAT_BRACELET_SLAUGHTER_CHARGE_REGEX = Pattern.compile(
|
||||||
"Your bracelet of slaughter has (\\d{1,2}) charge[s]? left.");
|
"Your bracelet of slaughter has (\\d{1,2}) charge[s]? left.");
|
||||||
private static final Pattern EXPEDITIOUS_CHECK_PATTERN = Pattern.compile(
|
private static final Pattern CHAT_BRACELET_EXPEDITIOUS_CHARGE_REGEX = Pattern.compile(
|
||||||
"Your expeditious bracelet has (\\d{1,2}) charge[s]? left.");
|
"Your expeditious bracelet has (\\d{1,2}) charge[s]? left.");
|
||||||
private static final Pattern DODGY_PROTECT_PATTERN = Pattern.compile(
|
private static final Pattern DODGY_PROTECT_PATTERN = Pattern.compile(
|
||||||
"Your dodgy necklace protects you\\..*It has (\\d+) charges? left\\.");
|
"Your dodgy necklace protects you\\..*It has (\\d+) charges? left\\.");
|
||||||
private static final Pattern SLAUGHTER_ACTIVATE_PATTERN = Pattern.compile(
|
|
||||||
"Your bracelet of slaughter prevents your slayer count decreasing. It has (\\d{1,2}) charge[s]? left.");
|
|
||||||
private static final Pattern EXPEDITIOUS_ACTIVATE_PATTERN = Pattern.compile(
|
|
||||||
"Your expeditious bracelet helps you progress your slayer (?:task )?faster. It has (\\d{1,2}) charge[s]? left.");
|
|
||||||
private static final Pattern DODGY_BREAK_PATTERN = Pattern.compile(
|
private static final Pattern DODGY_BREAK_PATTERN = Pattern.compile(
|
||||||
"Your dodgy necklace protects you\\..*It then crumbles to dust\\.");
|
"Your dodgy necklace protects you\\..*It then crumbles to dust\\.");
|
||||||
private static final String RING_OF_RECOIL_BREAK_MESSAGE = "<col=7f007f>Your Ring of Recoil has shattered.</col>";
|
private static final String RING_OF_RECOIL_BREAK_MESSAGE = "<col=7f007f>Your Ring of Recoil has shattered.</col>";
|
||||||
@@ -331,11 +333,7 @@ public class ItemChargePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
Matcher dodgyCheckMatcher = DODGY_CHECK_PATTERN.matcher(message);
|
Matcher dodgyCheckMatcher = DODGY_CHECK_PATTERN.matcher(message);
|
||||||
Matcher slaughterCheckMatcher = SLAUGHTER_CHECK_PATTERN.matcher(message);
|
|
||||||
Matcher expeditiousCheckMatcher = EXPEDITIOUS_CHECK_PATTERN.matcher(message);
|
|
||||||
Matcher dodgyProtectMatcher = DODGY_PROTECT_PATTERN.matcher(message);
|
Matcher dodgyProtectMatcher = DODGY_PROTECT_PATTERN.matcher(message);
|
||||||
Matcher slaughterActivateMatcher = SLAUGHTER_ACTIVATE_PATTERN.matcher(message);
|
|
||||||
Matcher expeditiousActivateMatcher = EXPEDITIOUS_ACTIVATE_PATTERN.matcher(message);
|
|
||||||
Matcher dodgyBreakMatcher = DODGY_BREAK_PATTERN.matcher(message);
|
Matcher dodgyBreakMatcher = DODGY_BREAK_PATTERN.matcher(message);
|
||||||
Matcher bindingNecklaceCheckMatcher = BINDING_CHECK_PATTERN.matcher(event.getMessage());
|
Matcher bindingNecklaceCheckMatcher = BINDING_CHECK_PATTERN.matcher(event.getMessage());
|
||||||
Matcher bindingNecklaceUsedMatcher = BINDING_USED_PATTERN.matcher(event.getMessage());
|
Matcher bindingNecklaceUsedMatcher = BINDING_USED_PATTERN.matcher(event.getMessage());
|
||||||
@@ -347,6 +345,10 @@ public class ItemChargePlugin extends Plugin
|
|||||||
Matcher chronicleLastChargeMatcher = CHRONICLE_LAST_CHARGE_PATTERN.matcher(message);
|
Matcher chronicleLastChargeMatcher = CHRONICLE_LAST_CHARGE_PATTERN.matcher(message);
|
||||||
Matcher chronicleOutOfChargesMatcher = CHRONICLE_OUT_OF_CHARGES_PATTERN.matcher(message);
|
Matcher chronicleOutOfChargesMatcher = CHRONICLE_OUT_OF_CHARGES_PATTERN.matcher(message);
|
||||||
Matcher ringOfForgingCheckMatcher = RING_OF_FORGING_CHECK_PATTERN.matcher(message);
|
Matcher ringOfForgingCheckMatcher = RING_OF_FORGING_CHECK_PATTERN.matcher(message);
|
||||||
|
Matcher slaughterMatcher = CHAT_BRACELET_SLAUGHTER_REGEX.matcher(Text.removeTags(message));
|
||||||
|
Matcher expeditiousMatcher = CHAT_BRACELET_EXPEDITIOUS_REGEX.matcher(Text.removeTags(message));
|
||||||
|
Matcher slaughterChargeMatcher = CHAT_BRACELET_SLAUGHTER_CHARGE_REGEX.matcher(Text.removeTags(message));
|
||||||
|
Matcher expeditiousChargeMatcher = CHAT_BRACELET_EXPEDITIOUS_CHARGE_REGEX.matcher(Text.removeTags(message));
|
||||||
|
|
||||||
if (event.getType() == ChatMessageType.GAMEMESSAGE || event.getType() == ChatMessageType.SPAM)
|
if (event.getType() == ChatMessageType.GAMEMESSAGE || event.getType() == ChatMessageType.SPAM)
|
||||||
{
|
{
|
||||||
@@ -354,30 +356,30 @@ public class ItemChargePlugin extends Plugin
|
|||||||
{
|
{
|
||||||
notifier.notify("Your Ring of Recoil has shattered");
|
notifier.notify("Your Ring of Recoil has shattered");
|
||||||
}
|
}
|
||||||
|
else if (Text.removeTags(message).startsWith(CHAT_BRACELET_SLAUGHTER))
|
||||||
|
{
|
||||||
|
updateBraceletOfSlaughterCharges(slaughterMatcher.find() ? Integer.parseInt(slaughterMatcher.group(1)) : MAX_SLAUGHTER_CHARGES);
|
||||||
|
}
|
||||||
|
else if (Text.removeTags(message).startsWith(CHAT_BRACELET_EXPEDITIOUS))
|
||||||
|
{
|
||||||
|
updateExpeditiousCharges(expeditiousMatcher.find() ? Integer.parseInt(expeditiousMatcher.group(1)) : MAX_EXPEDITIOUS_CHARGES);
|
||||||
|
}
|
||||||
|
else if (slaughterChargeMatcher.find())
|
||||||
|
{
|
||||||
|
updateBraceletOfSlaughterCharges(Integer.parseInt(slaughterChargeMatcher.group(1)));
|
||||||
|
}
|
||||||
|
else if (expeditiousChargeMatcher.find())
|
||||||
|
{
|
||||||
|
updateExpeditiousCharges(Integer.parseInt(expeditiousChargeMatcher.group(1)));
|
||||||
|
}
|
||||||
else if (dodgyCheckMatcher.find())
|
else if (dodgyCheckMatcher.find())
|
||||||
{
|
{
|
||||||
updateDodgyNecklaceCharges(Integer.parseInt(dodgyCheckMatcher.group(1)));
|
updateDodgyNecklaceCharges(Integer.parseInt(dodgyCheckMatcher.group(1)));
|
||||||
}
|
}
|
||||||
else if (slaughterCheckMatcher.find())
|
|
||||||
{
|
|
||||||
updateBraceletOfSlaughterCharges(Integer.parseInt(slaughterCheckMatcher.group(1)));
|
|
||||||
}
|
|
||||||
else if (expeditiousCheckMatcher.find())
|
|
||||||
{
|
|
||||||
updateExpeditiousCharges(Integer.parseInt(expeditiousCheckMatcher.group(1)));
|
|
||||||
}
|
|
||||||
else if (dodgyProtectMatcher.find())
|
else if (dodgyProtectMatcher.find())
|
||||||
{
|
{
|
||||||
updateDodgyNecklaceCharges(Integer.parseInt(dodgyProtectMatcher.group(1)));
|
updateDodgyNecklaceCharges(Integer.parseInt(dodgyProtectMatcher.group(1)));
|
||||||
}
|
}
|
||||||
else if (slaughterActivateMatcher.find())
|
|
||||||
{
|
|
||||||
updateBraceletOfSlaughterCharges(Integer.parseInt(slaughterActivateMatcher.group(1)));
|
|
||||||
}
|
|
||||||
else if (expeditiousActivateMatcher.find())
|
|
||||||
{
|
|
||||||
updateExpeditiousCharges(Integer.parseInt(expeditiousActivateMatcher.group(1)));
|
|
||||||
}
|
|
||||||
else if (dodgyBreakMatcher.find())
|
else if (dodgyBreakMatcher.find())
|
||||||
{
|
{
|
||||||
if (this.dodgyNotification)
|
if (this.dodgyNotification)
|
||||||
|
|||||||
@@ -393,8 +393,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
currentTask.setPaused(true);
|
currentTask.setPaused(true);
|
||||||
break;
|
break;
|
||||||
case LOGGED_IN:
|
case LOGGED_IN:
|
||||||
if (loginTick && this.amount != -1
|
if (loginTick && this.amount != -1 && !this.taskName.isEmpty() && currentTask.getTaskName() == null)
|
||||||
&& !this.taskName.isEmpty())
|
|
||||||
{
|
{
|
||||||
setTask(this.taskName, this.amount, this.initialAmount, true, this.taskLocation, this.lastCertainAmount, false);
|
setTask(this.taskName, this.amount, this.initialAmount, true, this.taskLocation, this.lastCertainAmount, false);
|
||||||
}
|
}
|
||||||
@@ -753,6 +752,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Task task = Task.getTask(taskName);
|
final Task task = Task.getTask(taskName);
|
||||||
|
int delta = slayerExp - cachedXp;
|
||||||
|
|
||||||
// null tasks are technically valid, it only means they arent explicitly defined in the Task enum
|
// null tasks are technically valid, it only means they arent explicitly defined in the Task enum
|
||||||
// allow them through so that if there is a task capture failure the counter will still work
|
// allow them through so that if there is a task capture failure the counter will still work
|
||||||
@@ -762,7 +762,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
// to the expected exp gain for the task.
|
// to the expected exp gain for the task.
|
||||||
if (taskKillExp == 0 || taskKillExp == slayerExp - cachedXp)
|
if (taskKillExp == 0 || taskKillExp == slayerExp - cachedXp)
|
||||||
{
|
{
|
||||||
killedOne();
|
killedOne(delta);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -780,9 +780,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
int killCount = estimateKillCount(potentialNPCs, gains);
|
int killCount = estimateKillCount(potentialNPCs, gains);
|
||||||
for (int i = 0; i < killCount; i++)
|
for (int i = 0; i < killCount; i++)
|
||||||
{
|
{
|
||||||
killedOne();
|
killedOne(delta);
|
||||||
int delta = slayerExp - cachedXp;
|
|
||||||
currentTask.setElapsedXp(currentTask.getElapsedXp() + delta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -840,7 +838,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
private void killedOne()
|
private void killedOne(int delta)
|
||||||
{
|
{
|
||||||
if (currentTask.getAmount() == 0)
|
if (currentTask.getAmount() == 0)
|
||||||
{
|
{
|
||||||
@@ -849,6 +847,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
|
|
||||||
currentTask.setAmount(currentTask.getAmount() - 1);
|
currentTask.setAmount(currentTask.getAmount() - 1);
|
||||||
currentTask.setElapsedKills(currentTask.getElapsedKills() + 1);
|
currentTask.setElapsedKills(currentTask.getElapsedKills() + 1);
|
||||||
|
currentTask.setElapsedXp(currentTask.getElapsedXp() + delta);
|
||||||
if (doubleTroubleExtraKill())
|
if (doubleTroubleExtraKill())
|
||||||
{
|
{
|
||||||
currentTask.setAmount(currentTask.getAmount() - 1);
|
currentTask.setAmount(currentTask.getAmount() - 1);
|
||||||
@@ -1208,31 +1207,13 @@ public class SlayerPlugin extends Plugin
|
|||||||
client.refreshChat();
|
client.refreshChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pointsLookup(ChatMessage chatMessage, String message)
|
private void pointsLookup(ChatMessage chatMessage, String message)
|
||||||
{
|
{
|
||||||
if (!this.pointsCommand)
|
if (!this.pointsCommand)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatMessageType type = chatMessage.getType();
|
|
||||||
|
|
||||||
final String player;
|
|
||||||
if (type.equals(ChatMessageType.PRIVATECHATOUT))
|
|
||||||
{
|
|
||||||
player = client.getLocalPlayer().getName();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player = Text.removeTags(chatMessage.getName())
|
|
||||||
.replace('\u00A0', ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Integer.toString(getPoints()) == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String response = new ChatMessageBuilder()
|
String response = new ChatMessageBuilder()
|
||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append("Slayer Points: ")
|
.append("Slayer Points: ")
|
||||||
@@ -1313,7 +1294,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPoints(int points)
|
private void setPoints(int points)
|
||||||
{
|
{
|
||||||
this.points = points;
|
this.points = points;
|
||||||
this.cachedPoints = points;
|
this.cachedPoints = points;
|
||||||
|
|||||||
Reference in New Issue
Block a user