Class SwitchCheck
java.lang.Object
privbot.mechanics.SwitchCheck
Proves a same-tick gear switch on later ticks, and backs off a switch that keeps failing.
Lifted from ElorinPvP's engine/GearRounds per-set verify and set-aside, without its churn and
per-piece accounting: ctx.loadouts.switchTo(..) sends every click in one call and proves nothing, so the
caller records the send here with sent(int, privbot.mechanics.GearSetup) and feeds each later tick's worn diff to observe(int, privbot.mechanics.SetupDiff).
SwitchCheck.State.DONE: a readable diff shows the setup worn. The run of failures starts again.SwitchCheck.State.PENDING: not worn yet, inside theverifyTickswindow that starts at the send tick.SwitchCheck.State.FAILED: still not worn on a readable diffverifyTicksor more ticks after the send;stillMissing()names the slots that never filled. 2 failures in a row makebackingOff(int)true for 5 ticks.SwitchCheck.State.UNREADABLE: the diff was null (equipment unreadable). It is never evidence: nothing is counted, the switch stays open, and the next readable diff decides.
observe(int, privbot.mechanics.SetupDiff) returns the last verdict (SwitchCheck.State.DONE before the first send).
Thread rule: mutable, single-owner. Feed it once per tick from the thread that reads the diff.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA verdict on the outstanding switch. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFailures in a row that start a back-off.static final intTicks a back-off lasts.static final intTicks a switch has to show up when none is given. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbackingOff(int tick) intfailures()One tick's verdict on the outstanding switch.voidRecords a switch that went out this tick; it replaces any outstanding one.setup()
-
Field Details
-
DEFAULT_VERIFY_TICKS
public static final int DEFAULT_VERIFY_TICKSTicks a switch has to show up when none is given.- See Also:
-
BACKOFF_AFTER
public static final int BACKOFF_AFTERFailures in a row that start a back-off.- See Also:
-
BACKOFF_TICKS
public static final int BACKOFF_TICKSTicks a back-off lasts.- See Also:
-
-
Constructor Details
-
SwitchCheck
public SwitchCheck()A check with 3 verify ticks. -
SwitchCheck
public SwitchCheck(int verifyTicks) - Parameters:
verifyTicks- ticks after the send before a missing piece counts as failed (at least 1)
-
-
Method Details
-
sent
Records a switch that went out this tick; it replaces any outstanding one.- Parameters:
tick- the tick the clicks went outsetup- the worn setup that was switched to
-
observe
One tick's verdict on the outstanding switch.- Parameters:
tick- the current tickwornDiff-SetupDiff.worn(setup, equipment)for the setup that was sent; null when unreadable- Returns:
- the verdict (see the class comment)
-
stillMissing
- Returns:
- the entries the last readable diff still missed (all of the setup right after
sent(int, privbot.mechanics.GearSetup))
-
failures
public int failures()- Returns:
- failed switches in a row (a DONE resets it)
-
backingOff
-
setup
- Returns:
- the setup last sent, or null
-