Skip to content

Commit

Permalink
chatcommands: allow cox pb to look at previous pb times from jagex
Browse files Browse the repository at this point in the history
  • Loading branch information
melkypie authored and Adam- committed Jun 24, 2020
1 parent d3e7998 commit 90aa9ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ 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 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>(?<pb>[0-9:]+)</col> \\(new personal best\\)</col>");
private static final Pattern RAIDS_DURATION_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> Personal best: </col><col=ff0000>(?<pb>[0-9:]+)</col>");
private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("^.*Theatre of Blood wave completion time: <col=ff0000>(?<pb>[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: (?<pb>[0-9:]+)");
private static final Pattern WINTERTODT_PATTERN = Pattern.compile("Your subdued Wintertodt count is: <col=ff0000>(\\d+)</col>");
Expand Down Expand Up @@ -365,6 +366,12 @@ else if (result.equals("were defeated"))
matchPb(matcher);
}

matcher = RAIDS_DURATION_PATTERN.matcher(message);
if (matcher.find())
{
matchPb(matcher);
}

matcher = TOB_WAVE_PB_PATTERN.matcher(message);
if (matcher.find())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,21 @@ public void testCoXKill()
verify(configManager).setConfiguration(eq("personalbest.adam"), eq("chambers of xeric"), eq(37 * 60 + 4));
}

@Test
public void testCoXKillUnknownPb()
{
when(configManager.getConfiguration("personalbest.adam", "chambers of xeric", int.class)).thenReturn(25 * 60 + 14);

ChatMessage chatMessage = new ChatMessage(null, FRIENDSCHATNOTIFICATION, "", "<col=ef20ff>Congratulations - your raid is complete!</col><br>Team size: <col=ff0000>3 players</col> Duration:</col> <col=ff0000>23:25</col> Personal best: </col><col=ff0000>20:19</col>", null, 0);
chatCommandsPlugin.onChatMessage(chatMessage);

chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Chambers of Xeric count is: <col=ff0000>52</col>.", null, 0);
chatCommandsPlugin.onChatMessage(chatMessage);

verify(configManager).setConfiguration("killcount.adam", "chambers of xeric", 52);
verify(configManager).setConfiguration("personalbest.adam", "chambers of xeric", 20 * 60 + 19);
}

@Test
public void testCoXKillNoPb()
{
Expand Down

0 comments on commit 90aa9ec

Please sign in to comment.