Class SetupDiff
java.lang.Object
privbot.mechanics.SetupDiff
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 Summary
Modifier and TypeMethodDescriptionstatic SetupDiffcarried(GearSetup wanted, ItemContainerSnapshot inventory) Compares the inventory with a carried setup.extras()missing()booleanstatic SetupDiffworn(GearSetup wanted, ItemContainerSnapshot equipment) Compares worn equipment with a worn setup.
-
Method Details
-
worn
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- aGearSetup.Kind.WORNsetupequipment- the equipment snapshot- Returns:
- the diff, or null when the snapshot is unavailable or the setup is not a worn one
-
carried
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- aGearSetup.Kind.CARRIEDsetupinventory- the inventory snapshot- Returns:
- the diff, or null when the snapshot is unavailable or the setup is not a carried one
-
missing
- Returns:
- the entries that are not met, in the setup's order
-
shortfall
- Returns:
- how many of each entry are still needed; carried setups only, empty for worn ones
-
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)
-