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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user