From ffafa3a91a64158c8620d08dfcf7eb7b6d5b30d8 Mon Sep 17 00:00:00 2001 From: melkypie <5113962+melkypie@users.noreply.github.com> Date: Sun, 28 Jun 2020 17:17:09 +0300 Subject: [PATCH] loot tracker: add ability to have end of raid tob chest loot value in a chatmessage --- .../loottracker/LootTrackerPlugin.java | 2 +- .../loottracker/LootTrackerPluginTest.java | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index 6d31251008..de4f6c1ed7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -547,7 +547,7 @@ public class LootTrackerPlugin extends Plugin .map(item -> new ItemStack(item.getId(), item.getQuantity(), client.getLocalPlayer().getLocalLocation())) .collect(Collectors.toList()); - if (config.showRaidsLootValue() && event.equals("Chambers of Xeric")) + if (config.showRaidsLootValue() && (event.equals("Theatre of Blood") || event.equals("Chambers of Xeric"))) { long totalValue = items.stream() .filter(item -> item.getId() > -1) diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java index 43d554ea3e..4b74201060 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java @@ -45,6 +45,7 @@ import net.runelite.api.ItemID; import net.runelite.api.IterableHashTable; import net.runelite.api.MessageNode; import net.runelite.api.Player; +import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.WidgetLoaded; @@ -243,4 +244,45 @@ public class LootTrackerPluginTest QueuedMessage queuedMessage = captor.getValue(); assertEquals("Your loot is worth around 1,100,000,252 coins.", queuedMessage.getRuneLiteFormattedMessage()); } + + @Test + public void testToBRaidsLootValue() + { + when(lootTrackerConfig.priceType()).thenReturn(LootTrackerPriceType.HIGH_ALCHEMY); + when(lootTrackerConfig.showRaidsLootValue()).thenReturn(true); + + LootTrackerPlugin spyPlugin = Mockito.spy(lootTrackerPlugin); + // Make sure we don't execute addLoot, so we don't have to mock LootTrackerPanel and everything else also + doNothing().when(spyPlugin).addLoot(anyString(), anyInt(), any(LootRecordType.class), anyCollection()); + + ItemContainer itemContainer = mock(ItemContainer.class); + when(itemContainer.getItems()).thenReturn(new Item[]{ + new Item(ItemID.SCYTHE_OF_VITUR, 1), + new Item(ItemID.MAHOGANY_SEED, 10) + }); + when(client.getItemContainer(InventoryID.THEATRE_OF_BLOOD_CHEST)).thenReturn(itemContainer); + + ItemComposition compScythe = mock(ItemComposition.class); + when(itemManager.getItemComposition(ItemID.SCYTHE_OF_VITUR)).thenReturn(compScythe); + when(compScythe.getHaPrice()).thenReturn(60_000_000); + + ItemComposition compSeed = mock(ItemComposition.class); + when(itemManager.getItemComposition(ItemID.MAHOGANY_SEED)).thenReturn(compSeed); + when(compSeed.getHaPrice()).thenReturn(2_102); + + when(client.getBaseX()).thenReturn(3232); + when(client.getBaseY()).thenReturn(4320); + LocalPoint localPoint = new LocalPoint(0, 0); + when(client.getLocalPlayer().getLocalLocation()).thenReturn(localPoint); + + WidgetLoaded widgetLoaded = new WidgetLoaded(); + widgetLoaded.setGroupId(WidgetID.THEATRE_OF_BLOOD_GROUP_ID); + spyPlugin.onWidgetLoaded(widgetLoaded); + + ArgumentCaptor captor = ArgumentCaptor.forClass(QueuedMessage.class); + verify(chatMessageManager).queue(captor.capture()); + + QueuedMessage queuedMessage = captor.getValue(); + assertEquals("Your loot is worth around 60,021,020 coins.", queuedMessage.getRuneLiteFormattedMessage()); + } }