Class WEALTH

java.lang.Object
net.pottercraft.ollivanders2.effect.O2Effect
net.pottercraft.ollivanders2.effect.WEALTH

public class WEALTH extends O2Effect
Wealth effect that periodically grants the affected player magical currency.

WEALTH is a beneficial effect that periodically generates magical currency coins and adds them to the target player's inventory. Every 120 game ticks (6 seconds), the effect generates a random coin based on weighted probability influenced by the strength multiplier. The higher the strength, the more likely the player receives high-value coins (Galleons) instead of low-value coins (Knuts). The probability distribution is: strength-adjusted random % 100, with Galleons (>90%), Sickles (>60%), and Knuts (default). The effect is detectable by both mind-reading spells (Legilimens) and information spells (Informous) which report the target "feels fortunate".

Wealth Configuration:

  • Generation interval: every 120 game ticks (6 seconds)
  • Coin types: Galleon (high value), Sickle (medium value), Knut (low value)
  • Strength parameter: multiplies random value to affect coin probability
  • Probability calculation: (random % 100) * strength
  • Detection text: "feels fortunate"
  • Constructor Details

    • WEALTH

      public WEALTH(@NotNull @NotNull Ollivanders2 plugin, int duration, boolean isPermanent, @NotNull @NotNull UUID pid)
      Constructor for creating a wealth effect.

      Creates a wealth effect that periodically generates magical coins for the target player. Initializes the strength multiplier to 1 (normal probability). Detection text is set for both mind-reading spells (Legilimens) and information spells (Informous). The target player reference is acquired at initialization time.

      Parameters:
      plugin - a callback to the MC plugin
      duration - the duration of the wealth effect in game ticks
      isPermanent - is this effect permanent (does not age)
      pid - the unique ID of the player to grant wealth
  • Method Details

    • checkEffect

      public void checkEffect()
      Age the wealth effect and generate coins periodically.

      Called each game tick. This method ages the effect counter. Every 120 ticks (6 seconds), a random coin is generated based on weighted probability. The strength multiplier is applied to the random value to increase the chance of higher-value coins. Generated coins are immediately added to the target player's inventory.

      Specified by:
      checkEffect in class O2Effect
    • setStrength

      public void setStrength(int strength)
      Set the strength multiplier for coin probability generation.

      The strength multiplier affects the weighted probability of coin generation. A strength of 1 uses normal probability distribution. Higher values increase the likelihood of generating high-value coins (Galleons) over low-value coins (Knuts).

      Parameters:
      strength - a positive integer multiplier where 1 is normal strength
    • doRemove

      public void doRemove()
      Perform cleanup when the wealth effect is removed.

      The default implementation does nothing, as WEALTH has no persistent state to clean up. When removed, the player keeps all coins that were generated while the effect was active.

      Specified by:
      doRemove in class O2Effect