Class FreezeClock

java.lang.Object
privbot.mechanics.FreezeClock

public final class FreezeClock extends Object
The clock of a freeze on an opponent: when it should end, whether a move of theirs ended it by running out or by breaking, and the immunity after it.

Why the distinction matters: a move near the expected end is the freeze running out, and immunity follows it. Calling every move while they were believed frozen a "break" drops the immunity, and the next freeze is then cast into it. A move at expectedEnd - FREEZE_EXPIRY_EARLY_TICKS or later is an expiry.

Plain ints: the caller resolves the spell's length in seconds and its immunity ticks and passes them in. Whether a given server enforces freeze immunity at all is not verified here.

Pure; no client reads, any thread. From ElorinPvP.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    How a move of theirs relates to a running freeze.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A move this soon after the freeze graphic is the step already under way when it landed: the drawn tile trails the server tile by 0-1 ticks (from ElorinPvP).
    static final int
    A move this many ticks before the expected end, or later, is the freeze running out, not breaking: the drawn tile trails the server's, and the clock runs in plugin ticks (from ElorinPvP).
    static final int
    "Never happened".
  • Method Summary

    Modifier and Type
    Method
    Description
    classifyMove(int start, int expectedEnd, int moveTick)
    What a move of theirs at moveTick was, for a freeze that landed at start.
    static int
    expectedEnd(int start, int seconds)
    The first tick the freeze no longer holds them: start + ceil(seconds * 10 / 6) (a tick is 0.6 s).
    static int
    immuneUntil(int endedAt, FreezeClock.Move kind, int immunityTicks)
    The first tick they can be frozen again after a freeze that ended at endedAt, or NEVER.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NEVER

      public static final int NEVER
      "Never happened".
      See Also:
    • FREEZE_BROKEN_GRACE_TICKS

      public static final int FREEZE_BROKEN_GRACE_TICKS
      A move this soon after the freeze graphic is the step already under way when it landed: the drawn tile trails the server tile by 0-1 ticks (from ElorinPvP).
      See Also:
    • FREEZE_EXPIRY_EARLY_TICKS

      public static final int FREEZE_EXPIRY_EARLY_TICKS
      A move this many ticks before the expected end, or later, is the freeze running out, not breaking: the drawn tile trails the server's, and the clock runs in plugin ticks (from ElorinPvP).
      See Also:
  • Method Details

    • expectedEnd

      public static int expectedEnd(int start, int seconds)
      The first tick the freeze no longer holds them: start + ceil(seconds * 10 / 6) (a tick is 0.6 s).
    • classifyMove

      public static FreezeClock.Move classifyMove(int start, int expectedEnd, int moveTick)
      What a move of theirs at moveTick was, for a freeze that landed at start.
    • immuneUntil

      public static int immuneUntil(int endedAt, FreezeClock.Move kind, int immunityTicks)
      The first tick they can be frozen again after a freeze that ended at endedAt, or NEVER.