chat commands: support parsing team size pbs off adventure log
This commit is contained in:
@@ -107,7 +107,7 @@ import org.apache.commons.text.WordUtils;
|
||||
public class ChatCommandsPlugin extends Plugin
|
||||
{
|
||||
private static final Pattern KILLCOUNT_PATTERN = Pattern.compile("Your (?:completion count for |subdued |completed )?(.+?) (?:(?:kill|harvest|lap|completion) )?(?:count )?is: <col=ff0000>(\\d+)</col>");
|
||||
private static final String TEAM_SIZES = "(?<teamsize>\\d+(?:\\+|-\\d+)? players|Solo)";
|
||||
private static final String TEAM_SIZES = "(?<teamsize>\\d+(?:\\+|-\\d+)? players?|Solo)";
|
||||
private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("<col=ef20ff>Congratulations - your raid is complete!</col><br>Team size: <col=ff0000>" + TEAM_SIZES + "</col> Duration:</col> <col=ff0000>(?<pb>[0-9:]+(?:\\.[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>" + TEAM_SIZES + "</col> Duration:</col> <col=ff0000>[0-9:.]+</col> Personal best: </col><col=ff0000>(?<pb>[0-9:]+(?:\\.[0-9]+)?)</col>");
|
||||
private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)(?:(?:Fight |Lap |Challenge |Corrupted challenge )?duration:|Subdued in|(?<!total )completion time:) <col=[0-9a-f]{6}>[0-9:.]+</col>\\. Personal best: (?:<col=ff0000>)?(?<pb>[0-9:]+(?:\\.[0-9]+)?)");
|
||||
@@ -115,7 +115,7 @@ public class ChatCommandsPlugin extends Plugin
|
||||
private static final Pattern DUEL_ARENA_WINS_PATTERN = Pattern.compile("You (were defeated|won)! You have(?: now)? won ([\\d,]+|one) duels?");
|
||||
private static final Pattern DUEL_ARENA_LOSSES_PATTERN = Pattern.compile("You have(?: now)? lost ([\\d,]+|one) duels?");
|
||||
private static final Pattern ADVENTURE_LOG_TITLE_PATTERN = Pattern.compile("The Exploits of (.+)");
|
||||
private static final Pattern ADVENTURE_LOG_PB_PATTERN = Pattern.compile("Fastest (?:kill|run)(?: - \\(Team size: " + TEAM_SIZES + "\\))?: (?<time>[0-9:]+(?:\\.[0-9]+)?)");
|
||||
private static final Pattern ADVENTURE_LOG_PB_PATTERN = Pattern.compile("Fastest (?:kill|run|Room time)(?: - \\(Team size: \\(?" + TEAM_SIZES + "\\)\\)?)?: (?<time>[0-9:]+(?:\\.[0-9]+)?)");
|
||||
private static final Pattern HS_PB_PATTERN = Pattern.compile("Floor (?<floor>\\d) time: <col=ff0000>(?<floortime>[0-9:]+(?:\\.[0-9]+)?)</col>(?: \\(new personal best\\)|. Personal best: (?<floorpb>[0-9:]+(?:\\.[0-9]+)?))" +
|
||||
"(?:<br>Overall time: <col=ff0000>(?<otime>[0-9:]+(?:\\.[0-9]+)?)</col>(?: \\(new personal best\\)|. Personal best: (?<opb>[0-9:]+(?:\\.[0-9]+)?)))?");
|
||||
private static final Pattern HS_KC_FLOOR_PATTERN = Pattern.compile("You have completed Floor (\\d) of the Hallowed Sepulchre! Total completions: <col=ff0000>([0-9,]+)</col>\\.");
|
||||
@@ -673,7 +673,6 @@ public class ChatCommandsPlugin extends Plugin
|
||||
for (int i = 0; i < text.length; ++i)
|
||||
{
|
||||
String boss = longBossName(text[i]);
|
||||
double pb = Double.MAX_VALUE;
|
||||
|
||||
for (i = i + 1; i < text.length; ++i)
|
||||
{
|
||||
@@ -683,19 +682,35 @@ public class ChatCommandsPlugin extends Plugin
|
||||
break;
|
||||
}
|
||||
|
||||
// Some bosses have multiple pbs for each team size, just use the lowest
|
||||
Matcher matcher = ADVENTURE_LOG_PB_PATTERN.matcher(line);
|
||||
if (matcher.find())
|
||||
{
|
||||
double s = timeStringToSeconds(matcher.group("time"));
|
||||
pb = Math.min(pb, s);
|
||||
}
|
||||
}
|
||||
final double s = timeStringToSeconds(matcher.group("time"));
|
||||
String teamSize = matcher.group("teamsize");
|
||||
if (teamSize != null)
|
||||
{
|
||||
// 3 player -> 3 players
|
||||
// 1 player -> Solo
|
||||
// Solo -> Solo
|
||||
// 2 players -> 2 players
|
||||
if (teamSize.equals("1 player"))
|
||||
{
|
||||
teamSize = "Solo";
|
||||
}
|
||||
else if (teamSize.endsWith("player"))
|
||||
{
|
||||
teamSize = teamSize + "s";
|
||||
}
|
||||
|
||||
if (pb < Double.MAX_VALUE)
|
||||
{
|
||||
log.debug("Found adventure log PB for {}: {}", boss, pb);
|
||||
setPb(boss, pb);
|
||||
log.debug("Found team-size adventure log PB for {} {}: {}", boss, teamSize, s);
|
||||
setPb(boss + " " + teamSize, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.debug("Found adventure log PB for {}: {}", boss, s);
|
||||
setPb(boss, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1087,6 +1087,10 @@ public class ChatCommandsPluginTest
|
||||
"Theatre of Blood",
|
||||
"Fastest Room time (former): <col=ffffff>18:45</col>",
|
||||
"Fastest Wave time (former): <col=ffffff>22:01</col>",
|
||||
"Fastest Room time - (Team size: (1 player): <col=ffffff>1:01:57.00</col>",
|
||||
"Fastest Overall time - (Team size: 1 player): <col=ffffff>1:06:40.20</col>",
|
||||
"Fastest Room time - (Team size: (2 player): <col=ffffff>22:43.80</col>",
|
||||
"Fastest Overall time - (Team size: 2 player): <col=ffffff>27:36.60</col>",
|
||||
"Fastest Room time - (Team size: (3 player): <col=ffffff>19:50</col>",
|
||||
"Fastest Overall time - (Team size: 3 player): <col=ffffff>22:47</col>",
|
||||
"Fastest Room time - (Team size: (4 player): <col=ffffff>17:38</col>",
|
||||
@@ -1138,7 +1142,10 @@ public class ChatCommandsPluginTest
|
||||
|
||||
verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 2033.0);
|
||||
verify(configManager).setRSProfileConfiguration("personalbest", "tempoross", 234.0);
|
||||
verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 1360.0); // the lowest time
|
||||
verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric solo", 60 * 28 + 7.);
|
||||
verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric 2 players", 60 * 24 + 40.);
|
||||
verify(configManager).setRSProfileConfiguration("personalbest", "theatre of blood solo", 3600 + 60 + 57.);
|
||||
verify(configManager).setRSProfileConfiguration("personalbest", "theatre of blood 3 players", 19 * 60 + 50.);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user