Class ShopOption
java.lang.Object
privbot.hooks.shop.ShopOption
A single purchasable option read off a live shop-slot widget, e.g.
"Buy 10" -> 10.
Options are never assumed to exist at a fixed action index — they are parsed from whatever
Widget.getActions() actually returns, so a server offering Buy 100 works with no
code change. label() preserves the exact live string so
Widgets.interact(widget, label) can match it and derive the real action index.
Buy X and Buy All are deliberately not parsed: Buy X needs chatbox
amount entry, and Buy All has no fixed quantity to reason about against a top-up target.
-
Method Summary
Modifier and TypeMethodDescriptionintamount()How many units this option buys per click.static ShopOptionbestFor(List<ShopOption> options, int remaining) Picks the largest option that does not exceedremaining.label()The exact action string as it appears on the widget — pass this toWidgets.interact.static ShopOptionAn option built from a known quantity rather than parsed from a widget.static List<ShopOption> Parses a widget's live action array into purchasable options, largest amount first.toString()
-
Method Details
-
label
The exact action string as it appears on the widget — pass this toWidgets.interact. -
amount
public int amount()How many units this option buys per click. Always >= 1. -
of
An option built from a known quantity rather than parsed from a widget.Needed where the buy options are not readable off a widget at all. On Impact they exist only in the live right-click menu (
'Buy-10 @lre@Guam leaf'), so the caller supplies the label the client will render and the quantity it stands for.- Throws:
IllegalArgumentException- whenamountis not positive
-
parse
Parses a widget's live action array into purchasable options, largest amount first. Null entries, blanks, and non-purchase actions are skipped. -
bestFor
Picks the largest option that does not exceedremaining. When every option is larger thanremaining, returns the smallest one — overshooting slightly beats deadlocking on a shop whose smallest increment exceeds what is still needed.- Returns:
- null when
optionsis empty
-
toString
-