chatcommands: add tob personal best tracking
Adds the ability to use theatre of blood !pb command, which will include the best wave/challenge time
This commit is contained in:
@@ -93,6 +93,8 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (.+) (?:kill|harvest|lap|completion) count is: <col=ff0000>(\\d+)</col>");
|
private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (.+) (?:kill|harvest|lap|completion) count is: <col=ff0000>(\\d+)</col>");
|
||||||
private static final Pattern RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: <col=ff0000>(\\d+)</col>");
|
private static final Pattern RAIDS_PATTERN = Pattern.compile("Your completed (.+) count is: <col=ff0000>(\\d+)</col>");
|
||||||
private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("<col=ef20ff>Congratulations - your raid is complete!</col><br>Team size: <col=ff0000>(?:[0-9]+ players|Solo)</col> Duration:</col> <col=ff0000>([0-9:]+)</col> \\(new personal best\\)</col>");
|
private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("<col=ef20ff>Congratulations - your raid is complete!</col><br>Team size: <col=ff0000>(?:[0-9]+ players|Solo)</col> Duration:</col> <col=ff0000>([0-9:]+)</col> \\(new personal best\\)</col>");
|
||||||
|
private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: <col=ff0000>([0-9:]+)</col> \\(Personal best!\\)");
|
||||||
|
private static final Pattern TOB_WAVE_DURATION_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: <col=ff0000>[0-9:]+</col><br></col>Personal best: ([0-9:]+)");
|
||||||
private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: <col=ff0000>(\\d+)</col>");
|
private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: <col=ff0000>(\\d+)</col>");
|
||||||
private static final Pattern BARROWS_PATTERN = Pattern.compile("Your Barrows chest count is: <col=ff0000>(\\d+)</col>");
|
private static final Pattern BARROWS_PATTERN = Pattern.compile("Your Barrows chest count is: <col=ff0000>(\\d+)</col>");
|
||||||
private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: <col=ff0000>[0-9:]+</col>\\. Personal best: ([0-9:]+)");
|
private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)^(?:Fight |Lap |Challenge |Corrupted challenge )?duration: <col=ff0000>[0-9:]+</col>\\. Personal best: ([0-9:]+)");
|
||||||
@@ -358,6 +360,18 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
matchPb(matcher);
|
matchPb(matcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matcher = TOB_WAVE_PB_PATTERN.matcher(message);
|
||||||
|
if (matcher.find())
|
||||||
|
{
|
||||||
|
matchPb(matcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
matcher = TOB_WAVE_DURATION_PATTERN.matcher(message);
|
||||||
|
if (matcher.find())
|
||||||
|
{
|
||||||
|
matchPb(matcher);
|
||||||
|
}
|
||||||
|
|
||||||
lastBossKill = null;
|
lastBossKill = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,10 +138,42 @@ public class ChatCommandsPluginTest
|
|||||||
@Test
|
@Test
|
||||||
public void testTheatreOfBlood()
|
public void testTheatreOfBlood()
|
||||||
{
|
{
|
||||||
|
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Wave 'The Final Challenge' complete! Duration: <col=ff0000>5:04</col><br>Theatre of Blood wave completion time: <col=ff0000>37:04</col> (Personal best!)", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: <col=ff0000>73</col>.", null, 0);
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: <col=ff0000>73</col>.", null, 0);
|
||||||
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
verify(configManager).setConfiguration("killcount.adam", "theatre of blood", 73);
|
verify(configManager).setConfiguration("killcount.adam", "theatre of blood", 73);
|
||||||
|
verify(configManager).setConfiguration("personalbest.adam", "theatre of blood", 37 * 60 + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTheatreOfBloodUnknownPB()
|
||||||
|
{
|
||||||
|
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Wave 'The Final Challenge' complete! Duration: <col=ff0000>5:04</col><br>Theatre of Blood wave completion time: <col=ff0000>38:17</col><br></col>Personal best: 37:04", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: <col=ff0000>73</col>.", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
|
verify(configManager).setConfiguration("killcount.adam", "theatre of blood", 73);
|
||||||
|
verify(configManager).setConfiguration("personalbest.adam", "theatre of blood", 37 * 60 + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTheatreOfBloodNoPB()
|
||||||
|
{
|
||||||
|
when(configManager.getConfiguration("personalbest.adam", "theatre of blood", int.class)).thenReturn(37 * 60 + 4); // 37:04
|
||||||
|
|
||||||
|
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Wave 'The Final Challenge' complete! Duration: <col=ff0000>5:04</col><br>Theatre of Blood wave completion time: <col=ff0000>38:17</col><br></col>Personal best: 37:10", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||||
|
|
||||||
|
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: <col=ff0000>73</col>.", null, 0);
|
||||||
|
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||||
|
|
||||||
|
verify(configManager).setConfiguration("killcount.adam", "theatre of blood", 73);
|
||||||
|
verify(configManager, never()).setConfiguration(eq("personalbest.adam"), eq("theatre of blood"), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user