LootTrackerBox extends JPanel { void addKill(final LootTrackerRecord record) { if (!matches(record)) { throw new IllegalArgumentException(record.toString()); } kills += record.getKills(); outer: for (LootTrackerItem item : record.getItems()) { final int mappedItemId = LootTrackerMapping.map(item.getId(), item.getName()); for (int idx = 0; idx < items.size(); ++idx) { LootTrackerItem i = items.get(idx); if (mappedItemId == i.getId()) { items.set(idx, new LootTrackerItem(i.getId(), i.getName(), i.getQuantity() + item.getQuantity(), i.getGePrice(), i.getHaPrice(), i.isIgnored())); continue outer; } } final LootTrackerItem mappedItem = mappedItemId == item.getId() ? item : new LootTrackerItem(mappedItemId, item.getName(), item.getQuantity(), item.getGePrice(), item.getHaPrice(), item.isIgnored()); items.add(mappedItem); } } LootTrackerBox(
		final ItemManager itemManager,
		final String id,
		final LootRecordType lootRecordType,
		@Nullable final String subtitle,
		final boolean hideIgnoredItems,
		final LootTrackerPriceType priceType,
		final boolean showPriceType,
		final BiConsumer<String, Boolean> onItemToggle,
		final BiConsumer<String, Boolean> onEventToggle,
		final boolean eventIgnored);   }
@Test public void testAddKill() { LootTrackerBox lootTrackerBox = new LootTrackerBox( mock(ItemManager.class), "Theatre of Blood", LootRecordType.EVENT, null, false, LootTrackerPriceType.GRAND_EXCHANGE, false, null, null, false); LootTrackerItem[] items = new LootTrackerItem[]{ new LootTrackerItem(ItemID.CLUE_SCROLL_MEDIUM, "Clue scroll (medium)", 1, 0, 0, false), new LootTrackerItem(ItemID.CLUE_SCROLL_MEDIUM_3602, "Clue scroll (medium)", 1, 0, 0, false), new LootTrackerItem(ItemID.GRACEFUL_HOOD_13579, "Graceful hood", 1, 0, 0, false), }; LootTrackerRecord lootTrackerRecord = new LootTrackerRecord( "Theatre of Blood", null, LootRecordType.EVENT, items, 42 ); lootTrackerBox.addKill(lootTrackerRecord); assertEquals(Arrays.asList( new LootTrackerItem(ItemID.CLUE_SCROLL_MEDIUM, "Clue scroll (medium)", 2, 0, 0, false), new LootTrackerItem(ItemID.GRACEFUL_HOOD_13579, "Graceful hood", 1, 0, 0, false) ), lootTrackerBox.getItems()); }