Class SwitchCheck

java.lang.Object
privbot.mechanics.SwitchCheck

public final class SwitchCheck extends Object
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).

With no switch outstanding, 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.

  • Field Details

    • DEFAULT_VERIFY_TICKS

      public static final int DEFAULT_VERIFY_TICKS
      Ticks a switch has to show up when none is given.
      See Also:
    • BACKOFF_AFTER

      public static final int BACKOFF_AFTER
      Failures in a row that start a back-off.
      See Also:
    • BACKOFF_TICKS

      public static final int BACKOFF_TICKS
      Ticks 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

      public void sent(int tick, GearSetup setup)
      Records a switch that went out this tick; it replaces any outstanding one.
      Parameters:
      tick - the tick the clicks went out
      setup - the worn setup that was switched to
    • observe

      public SwitchCheck.State observe(int tick, SetupDiff wornDiff)
      One tick's verdict on the outstanding switch.
      Parameters:
      tick - the current tick
      wornDiff - SetupDiff.worn(setup, equipment) for the setup that was sent; null when unreadable
      Returns:
      the verdict (see the class comment)
    • stillMissing

      public List<GearSetup.Entry> 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

      public boolean backingOff(int tick)
      Parameters:
      tick - the current tick
      Returns:
      true for 5 ticks after the failure that made 2 in a row
    • setup

      public GearSetup setup()
      Returns:
      the setup last sent, or null