Class LootSpec

java.lang.Object
privbot.mechanics.LootSpec

public final class LootSpec extends Object
Which ground items are worth picking up: by exact name, by id, or by stack value. Immutable.

What it proves: wants(java.lang.String, int, int) is true when the name is listed (exact, case-insensitive, trimmed), or the id is listed, or a value rule is set and quantity * price(name) >= threshold. With no names, ids or value rule nothing is wanted.

Unreadable looks like: a null name never matches by name or value. A price lookup that throws counts as "no value" for that item, never as wanted. range and maxPicks are settings for the caller; this class does not enforce them.

Thread rule: pure, safe on any thread, provided the price function is.

  • Method Details

    • builder

      public static LootSpec.Builder builder()
      Returns:
      a new builder: no rules, range 8, unlimited picks
    • range

      public int range()
      Returns:
      how many tiles around the player to look
    • maxPicks

      public int maxPicks()
      Returns:
      the most items to pick up per visit (Integer.MAX_VALUE for unlimited)
    • wants

      public boolean wants(String name, int id, int quantity)
      Parameters:
      name - the item name, or null
      id - the item id
      quantity - the stack size
      Returns:
      whether it is worth picking up