Class O2Divination

java.lang.Object
net.pottercraft.ollivanders2.divination.O2Divination
Direct Known Subclasses:
ASTROLOGY, CARTOMANCY, CARTOMANCY_TAROT, CENTAUR_DIVINATION, CRYSTAL_BALL, OVOMANCY, TASSEOMANCY

public abstract class O2Divination extends Object
Abstract parent class for all divination spell implementations in Ollivanders2.

Divination is a branch of magic that involves attempting to foresee the future or gather insights into past, present, and future events. This class provides the framework for creating randomized prophecies based on the specific divination method (astrology, cartomancy, crystal ball, etc.). Each divination subclass defines its own prophecy prefixes and accuracy level, which are combined with randomly selected effects to create a complete prophecy.

The prophecy generation process (divine()) follows a structured workflow:

  1. Calculate accuracy based on prophet's experience level and the divination method's maximum accuracy cap
  2. Select a random magical effect from the available divination effects pool
  3. Select a prophecy prefix from the subclass-specific list (method-specific phrasing)
  4. Determine the time of day and duration until the prophecy takes effect (1-4 days, varies by time)
  5. Construct a complete prophecy message combining all elements
  6. Create an O2Prophecy record and schedule the effect to occur at the designated time

Subclasses must define:

  • divinationType - The O2DivinationType constant for this divination method
  • maxAccuracy - The maximum accuracy percentage this divination method can achieve (caps prophet experience)
  • prophecyPrefix array - Method-specific prefixes (e.g., "Due to the influence of Mars," for astrology)
See Also:
  • Constructor Details

    • O2Divination

      public O2Divination(@NotNull @NotNull Ollivanders2 plugin, @NotNull @NotNull org.bukkit.entity.Player prophet, @NotNull @NotNull org.bukkit.entity.Player target, int experience)
      Constructor
      Parameters:
      plugin - a reference to the plugin
      prophet - the player making the prophecy
      target - the player the prophecy is about
      experience - the experience level of the prophet with this divination
  • Method Details

    • divine

      public void divine()
      Generate and execute a prophecy for the target player.

      This method orchestrates the complete prophecy generation workflow:

      1. Calculates the prophet's accuracy based on their experience level (capped by method's maxAccuracy)
      2. Randomly selects a magical effect from the 21 available divination effects
      3. Randomly selects a prophecy prefix from the method-specific list
      4. Determines the prophecy timing (time of day and scheduled day offset)
      5. Constructs the complete prophecy message with all components
      6. Creates an O2Prophecy record and schedules the effect to trigger at the designated time

      A complete prophecy message combines these components:

      • Method-specific prefix (e.g., "Due to the influence of Mars," for astrology)
      • Time of day (midnight, dawn, midday, sunset)
      • Scheduled day (tomorrow, in two days, in three days, in four days)
      • Target player's name
      • Effect description from the selected magical effect

      Example: "Due to the influence of Mars, at sunset tomorrow, Fred will fall into a deep sleep."