Class BuyPlan
(item, quantity) purchase lines.
Quantities are a top-up target: a line is satisfied when the inventory holds at least
quantity of the item, regardless of how many clicks were dispatched. Progress is therefore
always measured against a live inventory count, which makes the plan self-correcting when a click
is dropped and idempotent when the action is re-run inside a rule loop.
A line may also be skipped when it cannot be fulfilled (not stocked, out of stock,
purchase refused). Skipping retires the line from the work queue but does not mark it satisfied —
isComplete(java.util.function.ToIntFunction<java.lang.String>) still reports false, so partial success is never silently swallowed.
Pure logic: no client access, fully unit-testable.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOne(item, quantity)pair.static enumWhy a line was retired without reaching its target. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintactiveLine(ToIntFunction<String> inventoryCount) booleanisComplete(ToIntFunction<String> inventoryCount) True only when every line's inventory target is met, skipped or not.lines()static List<BuyPlan.Line> parseLines(String text) Parses a free-form item list into buy lines.static intremaining(BuyPlan.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, BuyPlan.Skip reason) Retires a line that cannot be fulfilled.
-
Constructor Details
-
BuyPlan
-
-
Method Details
-
parseLines
Parses a free-form item list into buy lines.Delegates to
ItemLines.parse(java.lang.String)— the same text means the same thing whether the items are being bought or withdrawn, so there is one parser. Kept here as the shop's entry point so existing callers and tests are unaffected.- Returns:
- never null; blank entries are dropped
-
lines
-
remaining
Units still needed to reach the line's target. Never negative. -
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. -
isComplete
True only when every line's inventory target is met, skipped or not. -
shortfallReport
Human-readable summary of every line that fell short, e.g."Bones 2/5 (OUT_OF_STOCK); Coal 0/3 (NOT_SOLD_HERE)".- Returns:
- empty string when all lines are satisfied
-