chat commands: add gg pb
This commit is contained in:
@@ -109,6 +109,7 @@ public class ChatCommandsPlugin extends Plugin
|
||||
private boolean logKills;
|
||||
private HiscoreEndpoint hiscoreEndpoint; // hiscore endpoint for current player
|
||||
private String lastBossKill;
|
||||
private int lastPb = -1;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@@ -223,7 +224,17 @@ public class ChatCommandsPlugin extends Plugin
|
||||
int kc = Integer.parseInt(matcher.group(2));
|
||||
|
||||
setKc(boss, kc);
|
||||
lastBossKill = boss;
|
||||
// We either already have the pb, or need to remember the boss for the upcoming pb
|
||||
if (lastPb > -1)
|
||||
{
|
||||
log.debug("Got out-of-order personal best for {}: {}", boss, lastPb);
|
||||
setPb(boss, lastPb);
|
||||
lastPb = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastBossKill = boss;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -291,19 +302,16 @@ public class ChatCommandsPlugin extends Plugin
|
||||
setKc("Barrows Chests", kc);
|
||||
}
|
||||
|
||||
if (lastBossKill != null)
|
||||
matcher = KILL_DURATION_PATTERN.matcher(message);
|
||||
if (matcher.find())
|
||||
{
|
||||
matcher = KILL_DURATION_PATTERN.matcher(message);
|
||||
if (matcher.find())
|
||||
{
|
||||
matchPb(matcher);
|
||||
}
|
||||
matchPb(matcher);
|
||||
}
|
||||
|
||||
matcher = NEW_PB_PATTERN.matcher(message);
|
||||
if (matcher.find())
|
||||
{
|
||||
matchPb(matcher);
|
||||
}
|
||||
matcher = NEW_PB_PATTERN.matcher(message);
|
||||
if (matcher.find())
|
||||
{
|
||||
matchPb(matcher);
|
||||
}
|
||||
|
||||
lastBossKill = null;
|
||||
@@ -316,8 +324,19 @@ public class ChatCommandsPlugin extends Plugin
|
||||
if (s.length == 2)
|
||||
{
|
||||
int seconds = Integer.parseInt(s[0]) * 60 + Integer.parseInt(s[1]);
|
||||
log.debug("Got personal best for {}: {}", lastBossKill, seconds);
|
||||
setPb(lastBossKill, seconds);
|
||||
if (lastBossKill != null)
|
||||
{
|
||||
// Most bosses sent boss kill message, and then pb message, so we
|
||||
// use the remembered lastBossKill
|
||||
log.debug("Got personal best for {}: {}", lastBossKill, seconds);
|
||||
setPb(lastBossKill, seconds);
|
||||
lastPb = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Some bosses send the pb message, and then the kill message!
|
||||
lastPb = seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -296,4 +296,34 @@ public class ChatCommandsPluginTest
|
||||
verify(configManager).setConfiguration(eq("personalbest.adam"), eq("tzkal-zuk"), eq(134 * 60 + 52));
|
||||
verify(configManager).setConfiguration(eq("killcount.adam"), eq("tzkal-zuk"), eq(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGgNewPb()
|
||||
{
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Fight duration: <col=ff0000>1:36</col> (new personal best)", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your Grotesque Guardians kill count is: <col=ff0000>179</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
verify(configManager).setConfiguration(eq("personalbest.adam"), eq("grotesque guardians"), eq(96));
|
||||
verify(configManager).setConfiguration(eq("killcount.adam"), eq("grotesque guardians"), eq(179));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGgKill()
|
||||
{
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Fight duration: <col=ff0000>2:41</col>. Personal best: 2:14", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your Grotesque Guardians kill count is: <col=ff0000>32</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
verify(configManager).setConfiguration(eq("personalbest.adam"), eq("grotesque guardians"), eq(2 * 60 + 14));
|
||||
verify(configManager).setConfiguration(eq("killcount.adam"), eq("grotesque guardians"), eq(32));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user