Class BoostDosePolicy
java.lang.Object
privbot.mechanics.BoostDosePolicy
Decides when to drink another dose of a stat boost (overload, super combat, and so on) from the boost the account
actually shows. There are no client reads and no actions here, and no assumed effect duration. The caller confirms
the dose left the inventory before
consumed(long), then keeps feeding the observed boost to
observe(int, long), which says to stop if the boost never appeared within the settle window.
What it proves: a dose is "due" only when the boost was read, read as expired, no confirmed dose is still
awaiting its boost, and the retry throttle has passed. A confirmed dose with no observable boost by its deadline
fails closed (observe(int, long) returns false) instead of drinking repeatedly.
Unreadable looks like: a boost of Integer.MIN_VALUE. It is never expired and never due, and
maxBoost(int[], int[]) returns it for any incomplete or non-positive stat read.
Thread rule: not thread safe; keep it on the one worker thread that runs the upkeep. No client calls.
-
Constructor Summary
ConstructorsConstructorDescriptionBoostDosePolicy(Predicate<String> isDose, int expiredAtOrBelow, long settleMs, int maxFailures) -
Method Summary
Modifier and TypeMethodDescriptionvoidattempted(long now) A dose was tried but not confirmed consumed: throttle the next try.voidconsumed(long now) The dose was confirmed gone from the inventory: wait for its boost and clear the failure count.booleandue(int boost, long now) booleanexpired(int boost) booleanRead-only: true when the recorded failures have reachedmaxFailures.booleanWhetheritemNameis a dose of this boost.static intmaxBoost(int[] real, int[] current) The largest boost over the paired skills, so one drained skill cannot request another dose while others stay boosted.booleanobserve(int boost, long now) False means a confirmed dose never produced an observable boost; do not drink repeatedly.static BoostDosePolicyoverload()Overload flasks and potions, doses 1 to 6: expired at +4 or less, 9 s settle, three failures.booleanRecords a failed attempt (this changes state).voidreset()
-
Constructor Details
-
BoostDosePolicy
public BoostDosePolicy(Predicate<String> isDose, int expiredAtOrBelow, long settleMs, int maxFailures) - Parameters:
isDose- item names that are a dose of this boostexpiredAtOrBelow- the observed boost at or below which the effect counts as gonesettleMs- wait after an attempt, and the time a confirmed dose gets to show its boostmaxFailures-recordFailure()andhasFailed()report true at this many failures- Throws:
IllegalArgumentException- whenmaxFailures < 1orsettleMs < 0
-
-
Method Details
-
overload
Overload flasks and potions, doses 1 to 6: expired at +4 or less, 9 s settle, three failures. -
isDose
WhetheritemNameis a dose of this boost. A null name is not. -
maxBoost
public static int maxBoost(int[] real, int[] current) The largest boost over the paired skills, so one drained skill cannot request another dose while others stay boosted.realandcurrentare matching levels per skill. Any missing, mismatched or non-positive level givesInteger.MIN_VALUE(unreadable), never an expired boost. -
expired
public boolean expired(int boost) -
reset
public void reset() -
due
public boolean due(int boost, long now) -
attempted
public void attempted(long now) A dose was tried but not confirmed consumed: throttle the next try. -
consumed
public void consumed(long now) The dose was confirmed gone from the inventory: wait for its boost and clear the failure count. -
recordFailure
public boolean recordFailure()Records a failed attempt (this changes state). True oncemaxFailuresis reached. Only a confirmed dose (consumed(long)) orreset()clears the count. -
hasFailed
public boolean hasFailed()Read-only: true when the recorded failures have reachedmaxFailures. Records nothing. -
observe
public boolean observe(int boost, long now) False means a confirmed dose never produced an observable boost; do not drink repeatedly.
-