screenshot plugin: add tob story and hard mode screenshots

This commit is contained in:
Adam
2021-06-13 18:02:10 -04:00
parent 79b18d43aa
commit 35ddeebf04
2 changed files with 60 additions and 4 deletions

View File

@@ -139,7 +139,9 @@ public class ScreenshotPlugin extends Plugin
BARROWS,
COX,
COX_CM,
TOB
TOB,
TOB_SM,
TOB_HM
}
private KillType killType;
@@ -389,12 +391,12 @@ public class ScreenshotPlugin extends Plugin
}
}
if (chatMessage.startsWith("Your completed Theatre of Blood count is:"))
if (chatMessage.startsWith("Your completed Theatre of Blood"))
{
Matcher m = NUMBER_PATTERN.matcher(Text.removeTags(chatMessage));
if (m.find())
{
killType = KillType.TOB;
killType = chatMessage.contains("Hard Mode") ? KillType.TOB_HM : (chatMessage.contains("Story Mode") ? KillType.TOB_SM : KillType.TOB);
killCountNumber = Integer.valueOf(m.group());
return;
}
@@ -554,7 +556,7 @@ public class ScreenshotPlugin extends Plugin
}
case THEATRE_OF_BLOOD_REWARD_GROUP_ID:
{
if (killType != KillType.TOB)
if (killType != KillType.TOB && killType != KillType.TOB_SM && killType != KillType.TOB_HM)
{
return;
}
@@ -788,6 +790,12 @@ public class ScreenshotPlugin extends Plugin
return clueType;
}
@VisibleForTesting
KillType getKillType()
{
return killType;
}
@VisibleForTesting
int getKillCountNumber()
{

View File

@@ -36,6 +36,7 @@ import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID;
import static net.runelite.api.widgets.WidgetID.DIALOG_SPRITE_GROUP_ID;
import static net.runelite.api.widgets.WidgetID.LEVEL_UP_GROUP_ID;
import static net.runelite.api.widgets.WidgetInfo.DIALOG_SPRITE_TEXT;
@@ -68,6 +69,8 @@ public class ScreenshotPluginTest
private static final String BARROWS_CHEST = "Your Barrows chest count is <col=ff0000>310</col>";
private static final String CHAMBERS_OF_XERIC_CHEST = "Your completed Chambers of Xeric count is: <col=ff0000>489</col>.";
private static final String THEATRE_OF_BLOOD_CHEST = "Your completed Theatre of Blood count is: <col=ff0000>73</col>.";
private static final String THREATRE_OF_BLOOD_SM_CHEST = "Your completed Theatre of Blood: Story Mode count is: <col=ff0000>73</col>.";
private static final String THREATRE_OF_BLOOD_HM_CHEST = "Your completed Theatre of Blood: Hard Mode count is: <col=ff0000>73</col>.";
private static final String NOT_SO_VALUABLE_DROP = "<col=ef1020>Valuable drop: 6 x Bronze arrow (42 coins)</col>";
private static final String VALUABLE_DROP = "<col=ef1020>Valuable drop: Rune scimitar (25,600 coins)</col>";
private static final String UNTRADEABLE_DROP = "<col=ef1020>Untradeable drop: Rusty sword";
@@ -158,10 +161,55 @@ public class ScreenshotPluginTest
@Test
public void testTheatreOfBloodChest()
{
when(screenshotConfig.screenshotRewards()).thenReturn(true);
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Magic fTail", THEATRE_OF_BLOOD_CHEST, null, 0);
screenshotPlugin.onChatMessage(chatMessageEvent);
assertEquals(73, screenshotPlugin.getKillCountNumber());
assertEquals(ScreenshotPlugin.KillType.TOB, screenshotPlugin.getKillType());
WidgetLoaded widgetLoaded = new WidgetLoaded();
widgetLoaded.setGroupId(WidgetID.THEATRE_OF_BLOOD_REWARD_GROUP_ID);
screenshotPlugin.onWidgetLoaded(widgetLoaded);
verify(drawManager).requestNextFrameListener(any(Consumer.class));
}
@Test
public void testTheatreOfBloodSmChest()
{
when(screenshotConfig.screenshotRewards()).thenReturn(true);
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Magic fTail", THREATRE_OF_BLOOD_SM_CHEST, null, 0);
screenshotPlugin.onChatMessage(chatMessageEvent);
assertEquals(73, screenshotPlugin.getKillCountNumber());
assertEquals(ScreenshotPlugin.KillType.TOB_SM, screenshotPlugin.getKillType());
WidgetLoaded widgetLoaded = new WidgetLoaded();
widgetLoaded.setGroupId(WidgetID.THEATRE_OF_BLOOD_REWARD_GROUP_ID);
screenshotPlugin.onWidgetLoaded(widgetLoaded);
verify(drawManager).requestNextFrameListener(any(Consumer.class));
}
@Test
public void testTheatreOfBloodHmChest()
{
when(screenshotConfig.screenshotRewards()).thenReturn(true);
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Magic fTail", THREATRE_OF_BLOOD_HM_CHEST, null, 0);
screenshotPlugin.onChatMessage(chatMessageEvent);
assertEquals(73, screenshotPlugin.getKillCountNumber());
assertEquals(ScreenshotPlugin.KillType.TOB_HM, screenshotPlugin.getKillType());
WidgetLoaded widgetLoaded = new WidgetLoaded();
widgetLoaded.setGroupId(WidgetID.THEATRE_OF_BLOOD_REWARD_GROUP_ID);
screenshotPlugin.onWidgetLoaded(widgetLoaded);
verify(drawManager).requestNextFrameListener(any(Consumer.class));
}
@Test