Class WithdrawPlan
(item, quantity) withdraw lines.
Quantities are a top-up target: a line is satisfied when the inventory holds at least
quantity of the item, however many clicks that took. Progress is measured against a live
inventory count, so a dropped click self-corrects and re-running the action inside a loop does not
stack withdrawals.
A line may be skipped when it cannot be fulfilled. Skipping retires it from the work
queue without marking it satisfied, so isComplete(java.util.function.ToIntFunction<java.lang.String>) still reports false and partial success
is never silently swallowed.
WithdrawPlan.Skip.INVENTORY_FULL retires one line, not the run. Free slots are shared, so a
full pack is usually terminal — but not always: a later line for something a stack is already held
of needs no new slot and can still succeed. Ending the whole plan on the first full-pack line would
silently drop those, so each line gets its own answer.
Pure logic: no client access, fully unit-testable.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOne(item, quantity)pair — the shared shape, so one parser serves buy and withdraw.static enumWhy a line was retired without reaching its target. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA quantity at or above this means "all of it", matching the GUI's 0-or-blank convention. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintactiveLine(ToIntFunction<String> inventoryCount) booleanisComplete(ToIntFunction<String> inventoryCount) True only when every line reached its target — numerically, or marked done for an all-line.lines()voidmarkSatisfied(int lineIndex) Retires anallline as done.static List<WithdrawPlan.Line> parseLines(String text) Parses a free-form item list, e.g.static intremaining(WithdrawPlan.Line line, int have) Units still needed to reach the line's target.shortfallReport(ToIntFunction<String> inventoryCount) Human-readable summary of every line that fell short, e.g.voidskip(int lineIndex, WithdrawPlan.Skip reason) Retires a line that cannot be fulfilled.
-
Field Details
-
ALL
public static final int ALLA quantity at or above this means "all of it", matching the GUI's 0-or-blank convention.- See Also:
-
-
Constructor Details
-
WithdrawPlan
-
-
Method Details
-
parseLines
Parses a free-form item list, e.g."Shark x10, Prayer potion(4) x4, Rune axe".- Returns:
- never null; blank entries are dropped
-
lines
-
remaining
Units still needed to reach the line's target. Never negative.An
allline always reports work outstanding — it has no numeric target to compare against — so callers must retire it throughmarkSatisfied(int)instead. -
activeLine
- Returns:
- index of the first line that is neither satisfied nor skipped, or -1 when nothing actionable remains
-
skip
Retires a line that cannot be fulfilled. Out-of-range indices are ignored. -
markSatisfied
public void markSatisfied(int lineIndex) Retires anallline as done. Out-of-range indices are ignored. -
isComplete
True only when every line reached its target — numerically, or marked done for an all-line. -
shortfallReport
Human-readable summary of every line that fell short, e.g."Shark 3/10 (INVENTORY_FULL); Coal 0/5 (NOT_IN_BANK)".- Returns:
- empty string when all lines are satisfied
-