Class PvpSnapshot

java.lang.Object
privbot.mechanics.PvpSnapshot

public final class PvpSnapshot extends Object
A detached copy of one tick of a PvP fight: the local player and the other players around it. Immutable, so it can be kept, compared with the next tick's and fed to the pure rules (OverheadWatch, StylePolicy, SpellEffects, OpponentLock) on any thread.

Produced by ctx.pvp.snapshot(..), which reads everything in one client-thread batch. A snapshot that exists proves the local player, its tile and the player list were read, so an empty opponents() means "nobody the query keeps is in range". Single fields that could not be read are null in their PlayerView.

Pure data: no client calls, safe on any thread.

  • Constructor Details

    • PvpSnapshot

      public PvpSnapshot(int tick, PlayerView local, List<PlayerView> opponents, Integer localSpecPercent)
      Parameters:
      tick - the client's tick count
      local - the local player
      opponents - the players the query kept
      localSpecPercent - the local special attack energy 0..100, or null when unreadable
  • Method Details

    • tick

      public int tick()
      Returns:
      the client's tick count when this was read
    • local

      public PlayerView local()
      Returns:
      the local player
    • opponents

      public List<PlayerView> opponents()
      Returns:
      the players the query kept (unmodifiable)
    • localSpecPercent

      public Integer localSpecPercent()
      Returns:
      the local special attack energy 0..100 (ctx.combat's read), or null when unreadable
    • find

      public PlayerView find(String name)
      Parameters:
      name - a player name (case and tags ignored)
      Returns:
      the opponent with that name, or null when none was kept
    • currentTarget

      public PlayerView currentTarget()
      Returns:
      the opponent the local player interacts with, or null when it interacts with no player, the interaction could not be read, or that player is not among opponents() (out of range or filtered out)