Calculate total count/value from loot records instead of boxes
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -63,9 +63,7 @@ class LootTrackerBox extends JPanel
|
||||
@Getter
|
||||
private final List<LootTrackerRecord> records = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private long totalPrice;
|
||||
|
||||
private boolean hideIgnoredItems;
|
||||
private BiConsumer<String, Boolean> onItemToggle;
|
||||
|
||||
@@ -116,7 +114,7 @@ class LootTrackerBox extends JPanel
|
||||
*
|
||||
* @return total amount of kills
|
||||
*/
|
||||
long getTotalKills()
|
||||
private long getTotalKills()
|
||||
{
|
||||
return hideIgnoredItems
|
||||
? records.stream().filter(r -> !Arrays.stream(r.getItems()).allMatch(LootTrackerItem::isIgnored)).count()
|
||||
@@ -169,9 +167,11 @@ class LootTrackerBox extends JPanel
|
||||
buildItems();
|
||||
|
||||
priceLabel.setText(StackFormatter.quantityToStackSize(totalPrice) + " gp");
|
||||
if (records.size() > 1)
|
||||
|
||||
final long kills = getTotalKills();
|
||||
if (kills > 1)
|
||||
{
|
||||
subTitleLabel.setText("x " + records.size());
|
||||
subTitleLabel.setText("x " + kills);
|
||||
}
|
||||
|
||||
repaint();
|
||||
|
||||
@@ -481,8 +481,35 @@ class LootTrackerPanel extends PluginPanel
|
||||
|
||||
private void updateOverall()
|
||||
{
|
||||
final long overallGp = boxes.stream().mapToLong(LootTrackerBox::getTotalPrice).sum();
|
||||
final long overallKills = boxes.stream().mapToLong(LootTrackerBox::getTotalKills).sum();
|
||||
long overallKills = 0;
|
||||
long overallGp = 0;
|
||||
|
||||
for (LootTrackerRecord record : records)
|
||||
{
|
||||
if (!record.matches(currentView))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int present = record.getItems().length;
|
||||
|
||||
for (LootTrackerItem item : record.getItems())
|
||||
{
|
||||
if (hideIgnoredItems && item.isIgnored())
|
||||
{
|
||||
present--;
|
||||
continue;
|
||||
}
|
||||
|
||||
overallGp += item.getPrice();
|
||||
}
|
||||
|
||||
if (present > 0)
|
||||
{
|
||||
overallKills++;
|
||||
}
|
||||
}
|
||||
|
||||
overallKillsLabel.setText(htmlLabel("Total count: ", overallKills));
|
||||
overallGpLabel.setText(htmlLabel("Total value: ", overallGp));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user