From c3c1222570f5190aa5f8bf42667335df8d564544 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 23 Aug 2021 16:20:48 -0400 Subject: [PATCH] chat commands: update to parse new adv log pb counters --- .../chatcommands/ChatCommandsPlugin.java | 58 ++-- .../chatcommands/ChatCommandsPluginTest.java | 306 ++++++++---------- 2 files changed, 161 insertions(+), 203 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index ca2c8bc71a..01b29fe814 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -69,7 +69,7 @@ import net.runelite.api.events.WidgetLoaded; import net.runelite.api.vars.AccountType; import net.runelite.api.widgets.Widget; import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID; -import static net.runelite.api.widgets.WidgetID.GENERIC_SCROLL_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID; import static net.runelite.api.widgets.WidgetID.KILL_LOGS_GROUP_ID; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; @@ -109,9 +109,9 @@ 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: (\\d+)"); - private static final String COX_TEAM_SIZES = "(?:\\d+(?:\\+|-\\d+)? players|Solo)"; - private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + COX_TEAM_SIZES + " Duration: (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); - private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + COX_TEAM_SIZES + " Duration: [0-9:.]+ Personal best: (?[0-9:]+(?:\\.[0-9]+)?)"); + private static final String TEAM_SIZES = "(?:\\d+(?:\\+|-\\d+)? players|Solo)"; + private static final Pattern RAIDS_PB_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + TEAM_SIZES + " Duration: (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); + private static final Pattern RAIDS_DURATION_PATTERN = Pattern.compile("Congratulations - your raid is complete!
Team size: " + TEAM_SIZES + " Duration: [0-9:.]+ Personal best: (?[0-9:]+(?:\\.[0-9]+)?)"); private static final Pattern TOB_WAVE_PB_PATTERN = Pattern.compile("Theatre of Blood wave completion time: (?[0-9:]+(?:\\.[0-9]+)?) \\(new personal best\\)"); private static final Pattern TOB_WAVE_DURATION_PATTERN = Pattern.compile("Theatre of Blood wave completion time: [0-9:.]+\\. Personal best: (?[0-9:]+(?:\\.[0-9]+)?)"); private static final Pattern KILL_DURATION_PATTERN = Pattern.compile("(?i)(?:(?:Fight |Lap |Challenge |Corrupted challenge )?duration:|Subdued in) [0-9:.]+\\. Personal best: (?:)?(?[0-9:]+(?:\\.[0-9]+)?)"); @@ -119,9 +119,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+) duels?"); private static final Pattern DUEL_ARENA_LOSSES_PATTERN = Pattern.compile("You have(?: now)? lost (\\d+) duels?"); private static final Pattern ADVENTURE_LOG_TITLE_PATTERN = Pattern.compile("The Exploits of (.+)"); - private static final Pattern ADVENTURE_LOG_COX_PB_PATTERN = Pattern.compile("Fastest (?:kill|run)(?: - \\(Team size: " + COX_TEAM_SIZES + "\\))?: ([0-9:]+(?:\\.[0-9]+)?)"); - private static final Pattern ADVENTURE_LOG_BOSS_PB_PATTERN = Pattern.compile("[a-zA-Z]+(?: [a-zA-Z]+)*"); - private static final Pattern ADVENTURE_LOG_PB_PATTERN = Pattern.compile("(" + ADVENTURE_LOG_BOSS_PB_PATTERN + "(?: - " + ADVENTURE_LOG_BOSS_PB_PATTERN + ")*) (?:" + ADVENTURE_LOG_COX_PB_PATTERN + "( )*)+"); + private static final Pattern ADVENTURE_LOG_PB_PATTERN = Pattern.compile("Fastest (?:kill|run)(?: - \\(Team size: " + TEAM_SIZES + "\\))?: ([0-9:]+(?:\\.[0-9]+)?)"); private static final Pattern HS_PB_PATTERN = Pattern.compile("Floor (?\\d) time: (?[0-9:]+(?:\\.[0-9]+)?)(?: \\(new personal best\\)|. Personal best: (?[0-9:]+(?:\\.[0-9]+)?))" + "(?:
Overall time: (?[0-9:]+(?:\\.[0-9]+)?)(?: \\(new personal best\\)|. Personal best: (?[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: ([0-9,]+)\\."); @@ -633,37 +631,47 @@ public class ChatCommandsPlugin extends Plugin } } + // Adventure log - Counters if (scrollInterfaceLoaded) { scrollInterfaceLoaded = false; if (client.getLocalPlayer().getName().equals(pohOwner)) { - String counterText = Text.sanitizeMultilineText(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT).getText()); - Matcher mCounterText = ADVENTURE_LOG_PB_PATTERN.matcher(counterText); - while (mCounterText.find()) + Widget parent = client.getWidget(WidgetInfo.DIARY_QUEST_WIDGET_TEXT); + // Each line is a separate static child + Widget[] children = parent.getStaticChildren(); + String[] text = Arrays.stream(children) + .map(Widget::getText) + .map(Text::removeTags) + .toArray(String[]::new); + + for (int i = 0; i < text.length; ++i) { - String bossName = longBossName(mCounterText.group(1)); - if (bossName.equalsIgnoreCase("chambers of xeric") || - bossName.equalsIgnoreCase("chambers of xeric challenge mode")) + String boss = longBossName(text[i]); + double pb = Double.MAX_VALUE; + + for (i = i + 1; i < text.length; ++i) { - Matcher mCoxRuns = ADVENTURE_LOG_COX_PB_PATTERN.matcher(mCounterText.group()); - double bestPbTime = Double.MAX_VALUE; - while (mCoxRuns.find()) + String line = text[i]; + if (line.isEmpty()) { - bestPbTime = Math.min(timeStringToSeconds(mCoxRuns.group(1)), bestPbTime); + break; } - // So we don't reset people's already saved PB's if they had one before the update - double currentPb = getPb(bossName); - if (currentPb == 0 || currentPb > bestPbTime) + + // Some bosses have multiple pbs for each team size, just use the lowest + Matcher matcher = ADVENTURE_LOG_PB_PATTERN.matcher(line); + if (matcher.find()) { - setPb(bossName, bestPbTime); + double s = timeStringToSeconds(matcher.group(1)); + pb = Math.min(pb, s); } } - else + + if (pb < Double.MAX_VALUE) { - String pbTime = mCounterText.group(2); - setPb(bossName, timeStringToSeconds(pbTime)); + log.debug("Found adventure log PB for {}: {}", boss, pb); + setPb(boss, pb); } } } @@ -722,7 +730,7 @@ public class ChatCommandsPlugin extends Plugin case KILL_LOGS_GROUP_ID: bossLogLoaded = true; break; - case GENERIC_SCROLL_GROUP_ID: + case DIARY_QUEST_GROUP_ID: scrollInterfaceLoaded = true; break; } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java index 7fa2c8dde5..5fe725c00f 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java @@ -30,6 +30,7 @@ import com.google.inject.Guice; import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; import java.io.IOException; +import java.util.Arrays; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; import net.runelite.api.ChatMessageType; @@ -46,7 +47,7 @@ import net.runelite.api.events.ScriptPostFired; import net.runelite.api.events.WidgetLoaded; import net.runelite.api.widgets.Widget; import static net.runelite.api.widgets.WidgetID.ADVENTURE_LOG_ID; -import static net.runelite.api.widgets.WidgetID.GENERIC_SCROLL_GROUP_ID; +import static net.runelite.api.widgets.WidgetID.DIARY_QUEST_GROUP_ID; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.chat.ChatCommandManager; import net.runelite.client.chat.ChatMessageManager; @@ -66,11 +67,9 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import org.mockito.junit.MockitoJUnitRunner; @@ -541,181 +540,6 @@ public class ChatCommandsPluginTest verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 20 * 60 + 19.2); } - @Test - public void testAdventureLogCountersPage() - { - Widget advLogWidget = mock(Widget.class); - Widget advLogExploitsTextWidget = mock(Widget.class); - when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); - when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + PLAYER_NAME); - when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); - when(configManager.getRSProfileConfiguration(anyString(), anyString(), any(Class.class))).thenReturn(2224.0); - - WidgetLoaded advLogEvent = new WidgetLoaded(); - advLogEvent.setGroupId(ADVENTURE_LOG_ID); - chatCommandsPlugin.onWidgetLoaded(advLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - String COUNTER_TEXT = "Duel Arena
Wins: 4
Losses: 2" + - "

Last Man Standing
Rank: 0" + - "

Treasure Trails
Beginner: 0
Easy: 7" + - "
Medium: 28
Hard: 108
Elite: 15" + - "
Master: 27
Rank: Novice" + - "

Chompy Hunting
Kills: 1,000
Rank: Ogre Expert" + - "

Order of the White Knights
Rank: Master
with a kill score of 1,300" + - "

TzHaar Fight Cave
Fastest run: 38:10" + - "

Inferno
Fastest run: -

Zulrah
" + - "Fastest kill: 5:48

Vorkath
Fastest kill: 1:21" + - "

Galvek
Fastest kill: -

Grotesque Guardians
" + - "Fastest kill: 2:49

Alchemical Hydra
Fastest kill: -" + - "

Hespori
Fastest kill: 0:57

Nightmare
" + - "Fastest kill: 3:30

The Gauntlet
Fastest run: -" + - "

The Corrupted Gauntlet
Fastest run: -

Fragment of Seren
Fastest kill: -" + - "

Chambers of Xeric
Fastest run - (Team size: 24+ players): 24:17" + - "

Chambers of Xeric - Challenge mode
Fastest run - (Team size: Solo): 22:15" + - "

Barbarian Assault
High-level gambles: 0

Fremennik spirits rested: 0"; - - Widget countersPage = mock(Widget.class); - when(countersPage.getText()).thenReturn(COUNTER_TEXT); - when(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT)).thenReturn(countersPage); - - WidgetLoaded countersLogEvent = new WidgetLoaded(); - countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); - chatCommandsPlugin.onWidgetLoaded(countersLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 38 * 60 + 10.0); - verify(configManager).setRSProfileConfiguration("personalbest", "zulrah", 5 * 60 + 48.0); - verify(configManager).setRSProfileConfiguration("personalbest", "vorkath", 60 + 21.0); - verify(configManager).setRSProfileConfiguration("personalbest", "grotesque guardians", 2 * 60 + 49.0); - verify(configManager).setRSProfileConfiguration("personalbest", "hespori", 57.0); - verify(configManager).setRSProfileConfiguration("personalbest", "nightmare", 3 * 60 + 30.0); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 24 * 60 + 17.0); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric challenge mode", 22 * 60 + 15.0); - } - - @Test - public void testAdventurerLogCountersPage2() - { - Widget advLogWidget = mock(Widget.class); - Widget advLogExploitsTextWidget = mock(Widget.class); - when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); - when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + PLAYER_NAME); - when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); - - WidgetLoaded advLogEvent = new WidgetLoaded(); - advLogEvent.setGroupId(ADVENTURE_LOG_ID); - chatCommandsPlugin.onWidgetLoaded(advLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - String COUNTER_TEXT = "Duel Arena
Wins: 12
Losses: 20" + - "

Last Man Standing
Rank: 0" + - "

Treasure Trails
Beginner: 1
Easy: 4" + - "
Medium: 35
Hard: 66
Elite: 2" + - "
Master: 0
Rank: Novice" + - "

Chompy Hunting
Kills: 300
Rank: Ogre Forester" + - "

Order of the White Knights
Rank: Unrated
with a kill score of 99" + - "

TzHaar Fight Cave
Fastest run: 65:12" + - "

Inferno
Fastest run: -

Zulrah
" + - "Fastest kill: 2:55

Vorkath
Fastest kill: 1:37" + - "

Galvek
Fastest kill: -

Grotesque Guardians
" + - "Fastest kill: -

Alchemical Hydra
Fastest kill: -" + - "

Hespori
Fastest kill: 1:42

Nightmare
" + - "Fastest kill: -

The Gauntlet
Fastest run: -" + - "

The Corrupted Gauntlet
Fastest run: -

Fragment of Seren
Fastest kill: -" + - "

Chambers of Xeric
Fastest run - (Team size: Solo): 21:23
Fastest run - (Team size: 3 players): 27:16" + - "

Chambers of Xeric - Challenge mode
Fastest run - (Team size: Solo): 34:30
Fastest run - (Team size: 4 players): 21:26" + - "

Barbarian Assault
High-level gambles: 0

Fremennik spirits rested: 0"; - - Widget countersPage = mock(Widget.class); - when(countersPage.getText()).thenReturn(COUNTER_TEXT); - when(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT)).thenReturn(countersPage); - - WidgetLoaded countersLogEvent = new WidgetLoaded(); - countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); - chatCommandsPlugin.onWidgetLoaded(countersLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 65 * 60 + 12.0); - verify(configManager).setRSProfileConfiguration("personalbest", "zulrah", 2 * 60 + 55.0); - verify(configManager).setRSProfileConfiguration("personalbest", "vorkath", 60 + 37.0); - verify(configManager).setRSProfileConfiguration("personalbest", "hespori", 60 + 42.0); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 21 * 60 + 23.0); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric challenge mode", 21 * 60 + 26.0); - } - - @Test - public void testAdventurerLogCountersPagePrecise() - { - Widget advLogWidget = mock(Widget.class); - Widget advLogExploitsTextWidget = mock(Widget.class); - when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); - when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + PLAYER_NAME); - when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); - - WidgetLoaded advLogEvent = new WidgetLoaded(); - advLogEvent.setGroupId(ADVENTURE_LOG_ID); - chatCommandsPlugin.onWidgetLoaded(advLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - String COUNTER_TEXT = "Duel Arena
Wins: 12
Losses: 20" + - "

Last Man Standing
Rank: 0" + - "

Treasure Trails
Beginner: 1
Easy: 4" + - "
Medium: 35
Hard: 66
Elite: 2" + - "
Master: 0
Rank: Novice" + - "

Chompy Hunting
Kills: 300
Rank: Ogre Forester" + - "

Order of the White Knights
Rank: Unrated
with a kill score of 99" + - "

TzHaar Fight Cave
Fastest run: 65:12.00" + - "

Inferno
Fastest run: -

Zulrah
" + - "Fastest kill: 2:55.20

Vorkath
Fastest kill: 1:37.20" + - "

Galvek
Fastest kill: -

Grotesque Guardians
" + - "Fastest kill: -

Alchemical Hydra
Fastest kill: -" + - "

Hespori
Fastest kill: 1:42.40

Nightmare
" + - "Fastest kill: -

The Gauntlet
Fastest run: -" + - "

The Corrupted Gauntlet
Fastest run: -

Fragment of Seren
Fastest kill: -" + - "

Chambers of Xeric
Fastest run - (Team size: Solo): 21:23.20
Fastest run - (Team size: 3 players): 27:16.40" + - "

Chambers of Xeric - Challenge mode
Fastest run - (Team size: Solo): 34:30.20
Fastest run - (Team size: 4 players): 21:26.00" + - "

Barbarian Assault
High-level gambles: 0

Fremennik spirits rested: 0"; - - Widget countersPage = mock(Widget.class); - when(countersPage.getText()).thenReturn(COUNTER_TEXT); - when(client.getWidget(WidgetInfo.GENERIC_SCROLL_TEXT)).thenReturn(countersPage); - - WidgetLoaded countersLogEvent = new WidgetLoaded(); - countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); - chatCommandsPlugin.onWidgetLoaded(countersLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - verify(configManager).setRSProfileConfiguration("personalbest", "tztok-jad", 65 * 60 + 12.0); - verify(configManager).setRSProfileConfiguration("personalbest", "zulrah", 2 * 60 + 55.2); - verify(configManager).setRSProfileConfiguration("personalbest", "vorkath", 60 + 37.2); - verify(configManager).setRSProfileConfiguration("personalbest", "hespori", 60 + 42.40); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric", 21 * 60 + 23.20); - verify(configManager).setRSProfileConfiguration("personalbest", "chambers of xeric challenge mode", 21 * 60 + 26.0); - } - - @Test - public void testNotYourAdventureLogCountersPage() - { - Widget advLogWidget = mock(Widget.class); - Widget advLogExploitsTextWidget = mock(Widget.class); - when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); - when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + "not the player"); - when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); - - WidgetLoaded advLogEvent = new WidgetLoaded(); - advLogEvent.setGroupId(ADVENTURE_LOG_ID); - chatCommandsPlugin.onWidgetLoaded(advLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - WidgetLoaded countersLogEvent = new WidgetLoaded(); - countersLogEvent.setGroupId(GENERIC_SCROLL_GROUP_ID); - chatCommandsPlugin.onWidgetLoaded(countersLogEvent); - chatCommandsPlugin.onGameTick(new GameTick()); - - verifyNoMoreInteractions(configManager); - } - @Test public void testPlayerSkillLookup() throws IOException { @@ -1122,4 +946,130 @@ public class ChatCommandsPluginTest // h:mm:ss assertEquals(2 * 3600 + 50 * 60 + 30.2, ChatCommandsPlugin.timeStringToSeconds("2:50:30.20"), DELTA); } + + @Test + public void testCounters() + { + final String[] log = { + "Chompy Hunting", + "Kills: 1,003", + "Rank: Ogre Expert", + "", + "Order of the White Knights", + "Rank: Master", + "with a kill score of 1,300", + "", + "TzHaar Fight Cave", + "Fastest run: 33:53", + "", + "Inferno", + "Fastest run: 2:02:20", + "", + "Zulrah", + "Fastest kill: 0:47", + "", + "Vorkath", + "Fastest kill: 1:04", + "", + "Galvek", + "Fastest kill: -", + "", + "Grotesque Guardians", + "Fastest kill: 1:20", + "", + "Alchemical Hydra", + "Fastest kill: 1:34", + "", + "Hespori", + "Fastest kill: 1:24", + "", + // Nightmare is here 3x! + "Nightmare", // including one only called "Nightmare" + "Fastest kill: -", // with no time + "", + "The Nightmare", + "Fastest kill - (Team size: 6+ players): 3:22", + "", + "The Nightmare", + "Fastest kill - (Team size: 6+ players): 3:22", + "", + "Phosani's Nightmare", + "Fastest kill: -", + "", + "The Gauntlet", + "Fastest run: -", + "", + "The Corrupted Gauntlet", + "Fastest run: -", + "", + "Fragment of Seren", + "Fastest kill: -", + "", + "Chambers of Xeric", + "Fastest run - (Team size: Solo): 28:07", + "Fastest run - (Team size: 2 players): 24:40", + "Fastest run - (Team size: 3 players): 25:35", + "Fastest run - (Team size: 4 players): 22:40", + "Fastest run - (Team size: 5 players): 23:00", + "Fastest run - (Team size: 6 players): 28:11", + "", + "Chambers of Xeric - Challenge mode", + "Fastest run - (Team size: 3 players): 45:41", + "", + "Theatre of Blood", + "Fastest Room time (former): 18:45", + "Fastest Wave time (former): 22:01", + "Fastest Room time - (Team size: (3 player): 19:50", + "Fastest Overall time - (Team size: 3 player): 22:47", + "Fastest Room time - (Team size: (4 player): 17:38", + "Fastest Overall time - (Team size: 4 player): 20:31", + "Fastest Room time - (Team size: (5 player): 18:45", + "Fastest Overall time - (Team size: 5 player): 22:01", + "", + "Tempoross", + "Fastest run: 3:54", + "", + "Barbarian Assault", + "High-level gambles: 0", + "", + "Fremennik spirits rested: 0", + }; + + // adv log + Widget advLogWidget = mock(Widget.class); + Widget advLogExploitsTextWidget = mock(Widget.class); + when(advLogWidget.getChild(ChatCommandsPlugin.ADV_LOG_EXPLOITS_TEXT_INDEX)).thenReturn(advLogExploitsTextWidget); + when(advLogExploitsTextWidget.getText()).thenReturn("The Exploits of " + PLAYER_NAME); + when(client.getWidget(WidgetInfo.ADVENTURE_LOG)).thenReturn(advLogWidget); + + // counters + when(client.getWidget(WidgetInfo.DIARY_QUEST_WIDGET_TEXT)).thenAnswer(a -> + { + Widget widget = mock(Widget.class); + Widget[] children = Arrays.stream(log) + .map(s -> + { + Widget w = mock(Widget.class); + when(w.getText()).thenReturn(s); + return w; + }) + .toArray(Widget[]::new); + when(widget.getStaticChildren()).thenReturn(children); + return widget; + }); + + WidgetLoaded advLogEvent = new WidgetLoaded(); + advLogEvent.setGroupId(ADVENTURE_LOG_ID); + chatCommandsPlugin.onWidgetLoaded(advLogEvent); + chatCommandsPlugin.onGameTick(new GameTick()); + + WidgetLoaded countersLogEvent = new WidgetLoaded(); + countersLogEvent.setGroupId(DIARY_QUEST_GROUP_ID); + chatCommandsPlugin.onWidgetLoaded(countersLogEvent); + chatCommandsPlugin.onGameTick(new GameTick()); + + 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 + } }