Class OffensivePrayerUpkeep

java.lang.Object
privbot.mechanics.OffensivePrayerUpkeep

public final class OffensivePrayerUpkeep extends Object
Which offensive prayer to keep on, and when to give one up. A prayer click toggles, and the server refuses a prayer the account has not unlocked or lacks the level for, so a chosen prayer that still reads off CONFIRM_TICKS ticks after each of MAX_UNCONFIRMED clicks is dropped for the session and the next one in the chain is kept instead (for ranged: Rigour, then Eagle Eye). Callers click only with prayer points left, so an empty prayer bar never costs a prayer its place.

Prayers are named by their in-game names ("Rigour", "Eagle Eye"), the same names ctx.prayer takes on every server.

What it proves: a prayer is dropped only after MAX_UNCONFIRMED clicks the caller recorded with clicked(java.lang.String, int) each failed to read "on" within CONFIRM_TICKS. An "off" read with no click behind it never counts against a prayer.

Unreadable looks like: the caller must not call observe(java.lang.String, boolean, int) when the prayer state could not be read. A state that is always read "off" (no working read) is what this class exists to catch, so such a prayer will be dropped after two clicks.

Thread rule: not thread safe; keep it on the one worker thread that ticks the prayer. No client calls.

  • Field Details

    • MAX_UNCONFIRMED

      public static final int MAX_UNCONFIRMED
      Clicks that never showed the prayer on before it is dropped.
      See Also:
    • CONFIRM_TICKS

      public static final int CONFIRM_TICKS
      Ticks after a click before an "off" read counts against it.
      See Also:
    • RANGED_CHAIN

      public static final List<String> RANGED_CHAIN
      Ranged offensive prayers, best first.
    • MAGIC_CHAIN

      public static final List<String> MAGIC_CHAIN
      Magic offensive prayers, best first.
    • MELEE_CHAIN

      public static final List<String> MELEE_CHAIN
      Melee offensive prayers, best first.
  • Constructor Details

    • OffensivePrayerUpkeep

      public OffensivePrayerUpkeep()
  • Method Details

    • pick

      public String pick(List<String> chain)
      The prayer to keep on: the first in chain not given up, or null (empty chain, or all dropped).
    • observe

      public String observe(String prayer, boolean on, int tick)
      This tick's read of the prayer being kept. Returns a line to log when the read drops it, else null. A click still within CONFIRM_TICKS is not judged yet.
    • awaiting

      public boolean awaiting(String prayer, int tick)
      Whether a click on prayer is still waiting for its read.
    • clicked

      public void clicked(String prayer, int tick)
    • reset

      public void reset()
      Death and a new run: a pending click is void. What was dropped stays dropped (an unlock does not come back).