Class SetupDiff

java.lang.Object
privbot.mechanics.SetupDiff

public final class SetupDiff extends Object
What a GearSetup still lacks, compared with the player's real containers, the same on every server.

An empty wanted setup is trivially satisfied. Callers (restock, equip) must treat it as "nothing to aim for", not as success; check GearSetup.isEmpty() first.

What a result proves: the snapshot was readable, so an empty missing() really means nothing is missing. Unreadable looks like: worn and carried(privbot.mechanics.GearSetup, privbot.hooks.container.ItemContainerSnapshot) return null for an unavailable snapshot (or a setup of the other kind); a null is never "satisfied" and never "everything is missing".

Thread rule: pure; build the snapshot on the worker thread and pass it in.

  • Method Details

    • worn

      public static SetupDiff worn(GearSetup wanted, ItemContainerSnapshot equipment)
      Compares worn equipment with a worn setup. A piece is missing when its slot does not hold the wanted id in at least the entry's minimum (a stackable such as ammunition only needs 1), so two pieces with the same name are counted per slot, never once.
      Parameters:
      wanted - a GearSetup.Kind.WORN setup
      equipment - the equipment snapshot
      Returns:
      the diff, or null when the snapshot is unavailable or the setup is not a worn one
    • carried

      public static SetupDiff carried(GearSetup wanted, ItemContainerSnapshot inventory)
      Compares the inventory with a carried setup. Each entry's shortfall is the wanted quantity less what is carried; a drink counts every dose of its family, so a (3) potion counts toward a wanted (4). Wanted entries of one family share the carried doses in setup order, so the total shortfall is wanted minus carried. Extras are carried items that no entry names by id and that are not a dose of a wanted drink.
      Parameters:
      wanted - a GearSetup.Kind.CARRIED setup
      inventory - the inventory snapshot
      Returns:
      the diff, or null when the snapshot is unavailable or the setup is not a carried one
    • missing

      public List<GearSetup.Entry> missing()
      Returns:
      the entries that are not met, in the setup's order
    • shortfall

      public Map<GearSetup.Entry,Integer> shortfall()
      Returns:
      how many of each entry are still needed; carried setups only, empty for worn ones
    • extras

      public List<ItemContainerSnapshot.Item> extras()
      Returns:
      items present that the setup does not allow (for worn: not the wanted id in the wanted slot)
    • satisfied

      public boolean satisfied()
      Returns:
      true when nothing is missing (worn: missing() empty; carried: shortfall() empty)