Class WithdrawOption

java.lang.Object
privbot.hooks.bank.WithdrawOption

public final class WithdrawOption extends Object
One withdraw quantity PrivBot can actually send on this server, e.g. "Withdraw-10" -> 10.

Like a shop's buy options, each bank quantity is its own action, so the usable quantities are exactly the ones PrivBot knows how to send on this server. Any other quantity is not offered rather than guessed at.

Unlike ShopOption this type also models Withdraw-All, which has no fixed amount. "All" is only ever selected when the caller explicitly asks for everything — it is never chosen to satisfy a numeric target, where it would overshoot without bound.

  • Field Details

    • ALL

      public static final int ALL
      Sentinel amount for the unbounded Withdraw-All option.
      See Also:
  • Method Details

    • label

      public String label()
      The label the client renders for this option — carried into the dispatched menu entry.
    • amount

      public int amount()
      Units withdrawn per click, or ALL for the unbounded option.
    • isAll

      public boolean isAll()
      True for Withdraw-All, which has no fixed quantity.
    • of

      public static WithdrawOption of(String label, int amount)
      A fixed-quantity option.
      Throws:
      IllegalArgumentException - when amount is not positive
    • all

      public static WithdrawOption all(String label)
      The unbounded Withdraw-All option.
    • bestFor

      public static WithdrawOption bestFor(List<WithdrawOption> options, int remaining)
      Picks the largest fixed option that does not exceed remaining. When every fixed option is larger, returns the smallest one — overshooting slightly beats deadlocking on a bank whose smallest increment exceeds what is still needed.

      Withdraw-All is never returned: it cannot serve a numeric target.

      Parameters:
      options - any order; only fixed-quantity entries are considered
      Returns:
      null when options holds no fixed-quantity entry
    • allOf

      public static WithdrawOption allOf(List<WithdrawOption> options)
      The Withdraw-All entry, or null when this server has none PrivBot can send.
    • toString

      public String toString()
      Overrides:
      toString in class Object