Class StylePolicy

java.lang.Object
privbot.mechanics.StylePolicy

public final class StylePolicy extends Object
Which combat style to fight in against an opponent's protection prayer.

The core of ElorinPvP PvPPolicy's style choice (a style their overhead blocks is never chosen) plus AutoPvP StylePreferenceRoll's weighted pick among the styles that remain. Feed blocked from OverheadWatch.blockedSet(int) so a one-tick flick does not change the established block. This method rolls on every call; retain the chosen style separately if it should persist across ticks.

Pure; no client reads, any thread.

  • Method Details

    • choose

      public static CombatStyle choose(Set<CombatStyle> available, Set<CombatStyle> blocked, Map<CombatStyle,Integer> weights, Random random)
      Picks an available style that is not blocked, weighted.
      • Candidates are available minus blocked, in CombatStyle declaration order (so a seeded random gives the same pick whatever set implementation is passed).
      • A style's weight is weights.get(style); missing (or null weights) is 1, negative is 0. When every candidate weighs 0 the pick is even.
      • When every available style is blocked, or none is available, it returns null: the caller decides what to do. This method never picks a blocked style.
      Parameters:
      available - the styles the plugin can fight in now; null is none
      blocked - the styles their prayer blocks; null is none
      weights - relative preference per style; null is equal
      random - the source of the roll; null uses ThreadLocalRandom