Class ShopInterface
ctx.shop uses it on Impact, Elorin and SpawnPK.
A shop is a container, not a tree of slot widgets. These clients have no widget per stock item
carrying a "Buy 10" action, as an OSRS client does: the stock is one container, the same kind that holds
the inventory and the worn equipment.
The buy options exist only in the slot's right-click menu (Buy-1, Buy-5,
Buy-10, Buy-X, Value), and each quantity is its own action, so the quantities this class
offers are exactly the ones PrivBot knows how to send on this server. Nothing is guessed: any other quantity is
simply not offered. A buy is sent exactly as the player's own click on that slot and quantity.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanClicks the best available buy option forremainingunits.The purchase quantities PrivBot can send on this server, largest first.booleanOpens the Buy X amount prompt on a stock slot.The stock scan, as a copy: the oneopenState()just made when asked withinCACHE_TTL_MSof it, so a caller that checks the state and then reads the stock scans once.currentStock()limited to the containers the client confirms are drawn (the client reports them drawn): what the shop learner records, so a live-but-hidden panel is never learned as stock.voidPrints every item-bearing container the client holds.findStockSlot(String itemName, boolean partialMatch) Finds the stock slot holdingitemName.booleanhasBuyX()True when PrivBot can open the shop's Buy X amount prompt on this server.voidDrops the cached scan so the next query reads the shop again.booleanStrict gate for "should I (re)open the shop?": stale contents are not enough.booleanisOpen()True when a stock container with at least one item is live — i.e.Three-valued "is the shop on screen?" — TRUE drawn, FALSE definitely not, null unanswerable.intRemaining shop stock for a slot, or 0 when unreadable.
-
Constructor Details
-
ShopInterface
-
-
Method Details
-
invalidate
public void invalidate()Drops the cached scan so the next query reads the shop again. -
isOpen
public boolean isOpen()True when a stock container with at least one item is live — i.e. a shop is on screen. -
isDefinitelyOpen
public boolean isDefinitelyOpen()Strict gate for "should I (re)open the shop?": stale contents are not enough.A closed shop still reads as stocked. On Elorin a shop keeps its items after the interface closes, as the bank and the trade screens do. Gating the trade-open on
isOpen()would therefore skip the NPC click for anyone who had opened that shop earlier in the session, and every buy would go to a shop that is not on screen, which the server ignores.Answers true only when the client confirms the shop is drawn, so when that cannot be told the caller re-opens rather than assuming: a redundant trade click costs one tick, a skipped one costs the whole action.
-
openState
Three-valued "is the shop on screen?" — TRUE drawn, FALSE definitely not, null unanswerable.The two-valued form folds "cannot tell" into "closed", which is right for deciding whether to CLICK the NPC and wrong for deciding whether to BUY. On Elorin the answer is always null: a buy gated on
isDefinitelyOpen()would never happen.Callers must decide what null means for them. Opening treats it as "open anyway" (a redundant trade click costs a tick). Buying treats it as "try, and let the inventory delta be the proof" — the same rule the bank withdraw already follows, for the same reason.
-
currentStock
The stock scan, as a copy: the oneopenState()just made when asked withinCACHE_TTL_MSof it, so a caller that checks the state and then reads the stock scans once. -
drawnStock
currentStock()limited to the containers the client confirms are drawn (the client reports them drawn): what the shop learner records, so a live-but-hidden panel is never learned as stock. Empty when nothing is confirmed drawn or the adapter cannot answer. -
findStockSlot
-
stockOf
Remaining shop stock for a slot, or 0 when unreadable. -
buyOptions
The purchase quantities PrivBot can send on this server, largest first. -
buy
Clicks the best available buy option forremainingunits.- Returns:
- false when no quantity can be sent on this server, or dispatch failed
-
hasBuyX
public boolean hasBuyX()True when PrivBot can open the shop's Buy X amount prompt on this server.Buy-X buys any quantity in one dispatch instead of chunking into the 1/5/10 options, so 400 of something is one click and three keystrokes rather than forty clicks.
-
buyX
Opens the Buy X amount prompt on a stock slot.Dispatch only. The prompt then wants the amount typed and Enter, which is keyboard input and belongs with the keyboard helper in the caller — this class stays free of AWT, and the caller is where the game's listener-bearing canvas is already resolved.
- Returns:
- false when Buy X cannot be sent on this server, or dispatch was not possible
-
dumpDiagnostics
public void dumpDiagnostics()Prints every item-bearing container the client holds. Called when no shop is detected, so the real structure is visible in the console instead of a silent no-op: if the stock container sits belowMIN_SHOP_SLOTSor is theINVENTORY_SLOTSpanel, it shows up here and can be named with-Dprivbot.shop.containerWidget=<id>.
-